Results 1 to 7 of 7
  1. #1
    IamKJVonly is offline Advanced Beginner
    Windows 10 Access 2010 32bit
    Join Date
    Aug 2018
    Posts
    40

    What is the best way to push a button and have today's date put in a Date field

    I'm sorry but I just can't seem to find right thread for this problem

    I have a form which has a date field in it that I call "Date last accessed"
    and I want to update that date field to today's date either by clicking on the date field (which is best for me) or by clicking on another button that will update the date field for me.
    I could enter it manually, but this way will save me many errors.

    Thanks for ANY help you can give me as I'm finding out that the more I get into access the less I seem to know.

    Dave

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    In the desired event:

    Me.DateTextboxName = Date()

    The parentheses may get dropped.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,820
    The actual code is simple:
    Me!fieldname = Date()

    The trick is figuring out what event to put code into. Could use form BeforeUpdate to automatically populate field when record is committed.

    Do users need to see this field during data entry/edit?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  4. #4
    IamKJVonly is offline Advanced Beginner
    Windows 10 Access 2010 32bit
    Join Date
    Aug 2018
    Posts
    40
    Thanks guys: The following code worked


    Private Sub DB_DateLastRead_Click()


    Me.DB_DateLastRead = Date
    End Sub

    I think I'm making progress
    Dave

  5. #5
    davegri's Avatar
    davegri is online now Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,389
    Quote Originally Posted by IamKJVonly View Post
    Thanks guys: The following code worked


    Private Sub DB_DateLastRead_Click()


    Me.DB_DateLastRead = Date
    End Sub

    I think I'm making progress
    Dave

    You might want to use the doubleclick event. That will allow you to single click into the textbox without changing it if you need to type a date.

  6. #6
    IamKJVonly is offline Advanced Beginner
    Windows 10 Access 2010 32bit
    Join Date
    Aug 2018
    Posts
    40
    Thanks Denegri

    That is great idea. Boy I'm I glad you thought of it.

    Thanks again. It is much apricated
    Dave

  7. #7
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,820
    And add a label above textbox "Double click to enter today's date"
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 2
    Last Post: 03-12-2018, 08:16 AM
  2. Replies: 1
    Last Post: 11-26-2013, 09:25 AM
  3. Replies: 3
    Last Post: 02-04-2013, 05:24 PM
  4. Replies: 5
    Last Post: 10-12-2012, 11:00 AM
  5. Replies: 12
    Last Post: 04-26-2012, 04:01 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums