• Pull date from table for form (Access 2003)

    Home » Forums » AskWoody support » Productivity software by function » MS Access and database help » Pull date from table for form (Access 2003)

    Author
    Topic
    #456545

    I’d like to populate a label or text box or form caption with the date value from it’s table. How can this be done?

    Viewing 0 reply threads
    Author
    Replies
    • #1141224

      I assume that the date field is part of the record source of the form.

      The easiest way is to place a text box on the form and set its Control Source property to the name of the field (you can select the field name from the dropdown list). (If you wish, you can set the Locked property of the text box to Yes and the Enabled property to No so that the user can’t edit the date.)

      If you prefer a label: place a label on the form and name it lblDate.
      Create an event procedure for the On Current event of the form:

      Private Sub Form_Current()
      Me.lblDate.Caption = Me.DateField
      End Sub

      where DateField is the name of the date field.

      If you want to set the caption of the form itself:

      Private Sub Form_Current()
      Me.Caption = Me.DateField
      End Sub

      • #1141246

        Not really. It’s just a table property. DateCreated or DateModified are the only attributes I’ve seen in code, but accessing it has been quite a pain.

        • #1141247

          You could use the On Load or On Open event of the form, for example:

          Private Sub Form_Load()
          Me.Caption = CurrentData.AllTables(Me.RecordSource).DateCreated
          End Sub

          or if you want to specify a format:

          Private Sub Form_Load()
          Me.Caption = Format(CurrentData.AllTables(Me.RecordSource).DateCreated, “Short Date”)
          End Sub

    Viewing 0 reply threads
    Reply To: Pull date from table for form (Access 2003)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: