Update record problem - VBA

J

Jim Mills

Hi

I am trying to update a record in a table when a button is clicked by using
VBA. When the button is pressed, a report opens showing only the data
associated with a record. At the same time, I want to update a field in the
table with the current date/time. I need/would like to do this within the
VBA that executes on the button click.

This is the code behind the button: - DoCmd.OpenReport "Letter Out",
acPreview, , SchoolID = Forms!frmLetterSelect!SchoolID

It opens the repert in preview mode with the correct School identifed. I
want to update a field in the table associated with this record at the same
time and can't do it!!

Any ideas??? Many thanks. Jim
 
R

Roxie Aho

If the form is based on the table or an updateable query
that is based on the table and the date/time field is on
the form (it doesn't have to be visible), then the On
Click event of the button could look like this:
date/timefield=Now()
DoCmd.OpenReport etc

Roxie Aho
roxiea at usinternet.com
 
A

Albert D. Kallal

You need the following:

YouDateTimeField = now()
me.dirty = false ' force a diskwrite

DoCmd.OpenReport "Letter Out",
acPreview, , SchoolID = Forms!frmLetterSelect!SchoolID

Note the dirty command to force a disk write. If you make changes to the
record and then try and print,to he changes will NOT display until you save
the record...so, don't forget to save the record first BEFORE you launch the
report...
 

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