Automatically update to today's date

mariaw

Registered User.
Local time
Today, 07:07
Joined
Jun 9, 2006
Messages
88
Hi

I have a table which has a date field in it, where the default value is Now().

How do I get this field to automatically update in the table to "today's date"?

Thanks

Maria
 
Firstly, you should be entering data via a form and not direct into the table.

Then you can use the Now() or Date() function on the form.
Col
 
Unless you need to know the time of the entry, be sure to use the Date() function. Otherwise, using Between Date1 and Date2 will end up not picking up Date2.
 
How do I get this field to automatically update in the table to "today's date"?
In what context? After you change a record on a form? After you update a record with a query?
 
Hi Pat

Once the record has been saved into the table (by filling in the form) - I want the table to update one field to today's date each time it is opened

Maria
 
I think you would use the OnCurrent event for the form to set the field to Now(). Every time someone goes into the record, the date/time will be reset. Or are you talking about looking at it directly in the table.
 
You really want to update a record because someone scrolled through it? Updating a change date if something is changed is very common. You would do that in the form's BeforeUpdate event. To update a record that someone just passes through, you would use the Current event as suggested by grnzbra.

Me.DateField = Now() 'stores both current date and current time
or
Me.DateField = Date() 'stores only current date
 
I have tried the code suggested by Pat Hartman in BeforeUpdate event but it didn't work.
Then I changed it to OnCurrent and it didn't have the effect I wanted it to happen.
I have a date field set to =Date(), which works fine when I go to it first time, i.e. a fresh record. When I go into it again (like when I sell extended warranty) it doesn't update the date to today's.
I really need to do this guys and I'm sure there is a way.
Thanks in advance for your help.
 
What you have done (based on the information you have provided) is set the Default value. You need to write the code inside the Form's Before update..
Code:
Private Sub Form_BeforeUpdate(Cancel As Integer)
    Me.yourDateField = Date()
End Sub
 
Hi

I have a table which has a date field in it, where the default value is Now().

How do I get this field to automatically update in the table to "today's date"?

Thanks

Maria

For me I have a field in my table called cdate and set the default value to = now() and just change the format of the date and time. Evertime I create a record using my form is adding the current date or time which ever I choose. Simple and easy.
 
Hi,
Regarding:

Code:
Private Sub Form_BeforeUpdate(Cancel As Integer) Me.yourDateField = Date() End Sub

I was wondering if this works in Access 2007.

Can't seems to get it to work.
 
What you have done (based on the information you have provided) is set the Default value. You need to write the code inside the Form's Before update..
Code:
Private Sub Form_BeforeUpdate(Cancel As Integer)
    Me.yourDateField = Date()
End Sub
i have tried that but it didn't work on my access 2010.
is there any other way?
thanks for your help in advance.
 
OK, this is a very old thread. However, so far as I know, the Form_BeforeUpdate event is still legal and the code posted by our friend pr-eugin should still work even for Ac2019, but CERTAINLY for 2010. (I have 2010 myself.)

What is the result that you get that you believe to be incorrect? What did you do, what did you expect, what did you see?
 

Users who are viewing this thread

Back
Top Bottom