Results 1 to 7 of 7

Show Date and Time a Record is Created

  1. #1
    SierraJuliet's Avatar
    SierraJuliet is offline Competent Performer
    Windows 7 64bit Access 2013 64bit
    Join Date
    Dec 2017
    Location
    Earth
    Posts
    206

    Show Date and Time a Record is Created

    I am looking for a way to show both the date and time a record was created. I tried the =Date() and it only displays the date. It is missing time.

    I have a separate field to track when something was last changed. This includes the =Now().

  2. #2
    Ajax is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    7,257
    the now() function returns date and time
    the date() function returns just the date
    the time() function returns just the time

  3. #3
    SierraJuliet's Avatar
    SierraJuliet is offline Competent Performer
    Windows 7 64bit Access 2013 64bit
    Join Date
    Dec 2017
    Location
    Earth
    Posts
    206
    I tried =Date() and =Time() and they do not work in VBA code. I also tried it in the table field property and the =Time() does not work, it shows 0000.

    The =Now() is used for last time a record is edited, which I already have.

    It appears Access 2013 stopped supporting =Date() and =Time(). In VBA code =Date() automatically changes to = Date without (), which adds the date the record was created.

    Any more ideas for getting a separate date and time field to work in VBA code for when a record is created?

  4. #4
    Ajax is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    7,257
    I tried =Date() and =Time() and they do not work in VBA code.
    vba may remove the brackets because they are not required in VBA. to say they are not working implies either you are doing something wrong, or there is a problem with your installation of Access - unlikely since now() works for you.

    =Time() does not work, it shows 0000.
    suggest check your formatting, field types etc. if i type

    ?time()

    in the immediate window, I get


    01:39:05

    it appears Access 2013 stopped supporting =Date() and =Time().
    I would be very surprised if that was the case - millions of developers would be in uproar.

    Edit - you do know dates and times are stored as numbers?

  5. #5
    davegri is online now Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    1,957
    This sounds like you are trying to store a date/time value in a long integer. The time portion cannot be displayed in an integer, as by definition, no fractional part is allowed. To store a date or time, define the field in the table as Date/Time.

  6. #6
    SierraJuliet's Avatar
    SierraJuliet is offline Competent Performer
    Windows 7 64bit Access 2013 64bit
    Join Date
    Dec 2017
    Location
    Earth
    Posts
    206
    All,

    I store the date and time as date/time field property with the specific date and time formats desired selected for each record field.

    The Immediate Window allows and returns correct values for ?Now(), ?Time(), and ?Date(). For some reason these are not working when I incorporate them in my VBA code.

  7. #7
    SierraJuliet's Avatar
    SierraJuliet is offline Competent Performer
    Windows 7 64bit Access 2013 64bit
    Join Date
    Dec 2017
    Location
    Earth
    Posts
    206
    Please Disregard. The issue was the form was closing before the date and time could be added to respected fields. Side note: when these field's properties are set to "required" it prevents the database from closing as well, which is how I figured out the problem.

    I simply relocated the Module.Procedure "Something to Enter" in another spot on a form in the database and the problem is resolved. The date and time of creation now adds to the database as it should.

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

Similar Threads

  1. Replies: 8
    Last Post: 12-29-2014, 08:13 AM
  2. Replies: 6
    Last Post: 11-10-2014, 03:14 AM
  3. Replies: 15
    Last Post: 07-24-2013, 12:22 PM
  4. Replies: 4
    Last Post: 03-06-2013, 02:32 PM
  5. View Created date and time for key in Registry
    By startop10 in forum Programming
    Replies: 2
    Last Post: 01-21-2011, 01:52 PM

Posting Permissions

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