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().
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().
the now() function returns date and time
the date() function returns just the date
the time() function returns just the time
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?
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.I tried =Date() and =Time() and they do not work in VBA code.
suggest check your formatting, field types etc. if i type=Time() does not work, it shows 0000.
?time()
in the immediate window, I get
01:39:05
I would be very surprised if that was the case - millions of developers would be in uproar.it appears Access 2013 stopped supporting =Date() and =Time().
Edit - you do know dates and times are stored as numbers?
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.
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.
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.