Results 1 to 5 of 5
  1. #1
    Join Date
    Jan 2004
    Posts
    3

    Unanswered: Date/Time and the OnClick function?

    Probably a simple question for someone with more Access time than I have under my belt. I'd like to use Access for real-time data collection and entry, eliminating our paper data forms. One of the things I'd like my form to do is to allow the user to enter the date without having to type it in. They need to have some control over it, but not have to type it. So something like clicking the mouse in the cell, or creating a button and macro that inserts the current date/time would be great.

    Anyone know a simple way to do this?

  2. #2
    Join Date
    Sep 2002
    Location
    South Wales
    Posts
    580

    Lightbulb Default value

    Why not set the DEFAULT value for your field as Date()

    As the user creates a new RECORD, the date as of then would be automatically inserted.

    Or if you want it behind a button, put this code behind the onclick event of the button.

    forms!nameofyourform.nameofyourdatefieldontheform = Date()
    Windows Server 2003-8 / Terminal Services / SQL 2000 / Access 2003 / Office 2003-7 / Exchange 2003-7 / Blackberry Enterprise Server / AutoCAD / Lambert And Butler / Red Bull

  3. #3
    Join Date
    Jan 2004
    Posts
    3
    That would work, but I don't want Access to insert a date unless the user clicks the cell. We enter some data on the first day of field work, and some more data on the second day. Both days have a field for date, and I don't want the first day changed when the second day is entered (record gets edited). Does that make sense?
    The button function might work though.

  4. #4
    Join Date
    Sep 2003
    Posts
    83
    Originally posted by chnookie
    That would work, but I don't want Access to insert a date unless the user clicks the cell. We enter some data on the first day of field work, and some more data on the second day. Both days have a field for date, and I don't want the first day changed when the second day is entered (record gets edited). Does that make sense?
    The button function might work though.
    Try entering the above mentioned code in the 'On Got Focus' event of the Date field.

  5. #5
    Join Date
    Jan 2004
    Posts
    3

    Talking

    That worked!

    Took me awhile to get my syntax right (rookie!!), but it works. I can now click in the cell and it enters todays date. And tomorrow, I can do the same for me second date entry.

    Thanks a million gang.......

Posting Permissions

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