Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Auto Update Date field when form info updated

Status
Not open for further replies.

irishhelp

MIS
Nov 21, 2001
25
0
0
CA
I have a date field in my form that they would like to update any time a change is made on the form. How do I do this? I'm working in Access 97.
 
What is it that you are storing? As an example, let say the you are storing employee addresses, you can create a table that contains two columns, one with the employee's name (or ID) and another column called "last_updated". Everytime you make a change in the form (ex: when clicking the save button), in your code you edit the record containing the last_updated value to equal the current date (you can get the current date by using the Now() function).

Carmo
 
I'm storing basic demographic information, so what they'd like is that if you update the address field, the last date updated field would automatically update.

You mentioned code - I've added =Date() to the underlying table and to the default value for the field but it only inputs the date on new records. On the Save button that I have on the form, can I OnClick have it update the date field?
 
There are two general ways of updating a field in a table (in this case a "last_updated" field). You could use an Update Query or code the update by using "Edit" method of a recordset collection. Could you first tell me what field uniquely identifies each record (Primary Key.

Carmo
 
Here is your simple answer:

1. Put this code behind AfterUpdate event of any fields that you would like to also update you date field:

Me.YourFieldName.Value = Date <-- This will store only the date.

or

Me.YourFieldName.Value = Now() <--This will store the date and time.

Everytime the user moves from one field to another or clicks on any buttons (also put this code on the OnClick Event of that button as well) will update your date field.

:)WB
 
I added the code:
Me.EDATE.Value=Date on my firstname field but when I moved to another field I was told that &quot;The Macro or Macro group does not exist, or the macro is new and hasn't been saved. Note that when you enter the macrogroupname.macroname syntax in an argument you must specify the name the macro's macro group was last saved under.

Do I need to create a macro first?
Thanks
 
I typed in [EDATE].Value=Date() in the AfterUpdate property box in my lastname field. It tells me that [EDATE] is a macro that it can't find.
 
I'm assuming EDATE is the name of the text box holding the date field. If not, use the name of the text box instead of the name of the field.

 
Edate was the field on the form. I made a text box using the edate field, then entered [Text110].Value=Date() in the last name properties AfterUpdate but it tells me that it can't find the macro Text110.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top