Results 1 to 6 of 6
  1. #1
    Lounger
    Join Date
    Mar 2004
    Posts
    27
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Value (ACCESS 2003)

    How can I make a field in my form to auto populate? For example, I wanted the entry date field to auto populate with the current date as soon as I key in an entry on the first field of the form.

    Thank you.

  2. #2
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts

    Re: Default Value (ACCESS 2003)

    In the Design of the table, set the default value of the field to :=Date()
    Regards
    John



  3. #3
    Lounger
    Join Date
    Mar 2004
    Posts
    27
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Default Value (ACCESS 2003)

    That is what I already have. However, I do not want the audit date field populated until a value is entered on the first field on the tab order.

    Thank you.

  4. #4
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts

    Re: Default Value (ACCESS 2003)

    In that case you need to use the After Event of the first field on the form to set the value of AuditDate


    If isnull(me.AuditDate) then
    me.[AuditDate] = Date
    end if

    You need to test if AuditDate is null, otherwise the date will get updated if change the value of this first field at some later time.

    But I don't know why you would bother with this. Setting the default value in the table is simpler and completely reliable. Even though you see the date in new records before the record is created, that date does not 'stick' if you don't create the record.
    Regards
    John



  5. #5
    Lounger
    Join Date
    Mar 2004
    Posts
    27
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Default Value (ACCESS 2003)

    Thanks, I'll do that. Really if it was just me, I won't loose any sleep over it. It's the people who uses the database that's being bothered by it. Thanks for taking the time to look at this.

  6. #6
    Lounger
    Join Date
    Mar 2004
    Posts
    27
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Default Value (ACCESS 2003)

    I used the code below and it worked.

    Private Sub List2_Change()
    Text129 = Format(Date, "MM/DD/YYYY")
    End Sub

    Thanks again for your help.

Posting Permissions

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