Results 1 to 3 of 3
  1. #1
    2 Star Lounger
    Join Date
    Feb 2003
    Posts
    129
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default value -Form Field (97/Sp2)

    On a form each week I have an assistant add several names and the same date for each name. I would like to create a separate textbox on the form that would set a default value for the date field. That way she can easily change the default value each week. I know I can do it in the field properties for the date field, but I would rather do it right on the form.

    Could someone get me started on the code to do it.

    Thanks

    Paul

  2. #2
    Silver Lounger
    Join Date
    Jun 2002
    Location
    Cheadle, Staffordshire
    Posts
    2,177
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Default value -Form Field (97/Sp2)

    Paul

    You can set the default date by locating the properties for the field and then entering:-

    =Date()

    In the field which says "Default Value"
    This will enter the current date each time a new record is produced, and allow it to be edited.

  3. #3
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Default value -Form Field (97/Sp2)

    If the assistant types the date into the date field once, she can copy it in the next record by typing Ctrl+' (Ctrl+apostrophe).

    The code for a command button would look like this. For illustration purposes, I have assumed that the separate text box is named txtDefaultDate and that the date field is named dtmCheckDate.

    Private Sub txtDefaultDate_AfterUpdate()
    If Not IsNull(Me.txtDefaultDate) Then
    Me.dtmCheckDate.DefaultValue = "#" & Format(Me.txtDefaultDate, "mm/dd/yyyy") & "#"
    End If
    End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •