insert today's date in a field

J

Jim Guffey

I have a real basic question. I want for Access to automatically enter
today's date into a "Date Updated" field when the form is updated. I am not
talking about entering the date when the data is first entered into a form,
but when data on the form is changed.

I feel pretty qualified on queries, but am a novice on macros. The one I
developed does what I want, but then locks up the database. Not good.

Suggestions? Thanks!

Jim Guffey
 
A

Al Camp

Use the BeforeUpdate event of the form...
[Date Updated] = Date
When you create a new record this date and the [Date Created] will be equal,
but after that, [Date Updated] it will update whenever the form is
re-edited.
hth
Al Camp
Candia Computer Consulting - Candia NH
http://home.comcast.net/~cccsolutions
 
S

Steve Schapel

Jim,

Using macros, there would be two approaches you could take to this.

1. Make a macro using a SetValue action, and assign it on the Before
Update event of the form. The arguments for the SetValue action would
be like this...
Item: [Date Updated]
Expression: Date()

2. Make an Update Query to set the value of the Date Updated field for
the form's current record. The SQL of this quewry would look something
like this...
UPDATE YourTable SET [Date Updated] = Date() WHERE YourID =
[Forms]![YourForm]![YourID]
Then, make a macro using the OpenQuery action to run this Update, and
assign the macro on the form's After Update event. You might also want
to put a SetWarnings/No action in the macro ahead of the OpenQuery
action, to suppress the display of the action query confirmation message.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top