Access equivalent of Excel function today()

karthikcoep

Registered User.
Local time
Today, 15:30
Joined
Mar 4, 2009
Messages
40
I want to update my records to today's date.
Whenever I open a the access db the table which contains the date field should update automatically to today's date.

In excel this is done by today()

I tried using date() but the stored value is static, (it stores the date when that record was entered).

Is there any function to enter today's date.
 
Date()...same in Excel VBA.

I am very confused as to why using Date() or Today() or Now() or Anythingelseyoucanthinkof() has anything to do with the persistence of a date. One might also wonder (as I do) why you're storing the current date and/or time every time you look at a table.

If you're doing what you're supposed to be doing with Access, you will be viewing and updating your data via a bound form. If you want to update an audit field with the date/time whenever a record within a table has been modified, you can just update the field with Date() (or Now()) on the Form's before update event.
 
I will back George in saying that it makes no sense to store the current date each time the database is opened. It would obviously always have the current date.

Other than using VBA I can't think of anywhere that something could be entered on a form and produce a persistent date record in a bound field of a table.

I guess you are trying to include the date as a field in a data export. If so you would not write the date into a table but use a query which included the Date function to generate one of the fields.
 
Thanks for you guidance.
But I think I was not clear in getting my question right.
I use the table to perpare a report, which has to be signed by an examiner.
There is a "Date of examiner's signature" field in my table,
which I want to populate so that it gives today's date, so that I dont have to type todays date for all records whose reports I want to sign from him today.

I type in the remaining fields before hand, because I don't know the date when the examiner will come.
 
So in your form put the date in when you know it.

If you want the system to use the current date, one way is to add an event handler to the date field something like this:
Code:
Private Sub YourFieldName_Click()
    YourFieldName.Text = Date
End Sub

To get to this point, go to your form in design mode, show the properties for your field (right click menu if needed), go to the events tab, click on the ellipses (...) next to "On Click", select "Code Builder", and paste this code using your field name instead of mine.
 

Users who are viewing this thread

Back
Top Bottom