"Can't save record" error

  • Thread starter Thread starter Tom
  • Start date Start date
T

Tom

Since I have included a new field (DATETIMESTAMP) in a
table, I get the following MS-Access error in FORM view
when "CLOSING WINDOW".

*******************
"You can't save this record at this time. Microsoft
Access may have encountered an error while trying to save
a record. If you close this object now, the data changes
you made will be lost."
*******************


BACKGROUND INFO
===============
Essentially, the DATETIMESTAMP field is linked to a FORM
EVENT(AFTER UPDATE). Every time I make a change to the
record (any field since the function resides on the form),
the DATETIMESTAMP field should be updated. [By the way,
although I get the CANNOT SAVE RECORD error, the data is
saved anyhow].

I have put the following VBA code into the EVENT routine.

*******
Private Sub Form_AfterUpdate()
Me![DATETIMESTAMP] = Now()
End Sub
*******


Here's the sequence of what happens:
- I change a field value of any record
- Click "Save" (this won't give me an error yet). I also
can move to the next record via navigation buttons w/o
having the error. However, I cannot execute a command
button which requeries the form and "asks" for ID input of
another record.
- Click "Close Window"... NOW THIS IS WHEN THE ERROR
OCCURS (as described above).
- Again, even though I get this error message, the data
that was changed via the FORM was saved in the table.
- Finally, I verify the DATETIMESTAMP in the table. It
was saved properly.


QUESTION:
=========
1. Why do I get this error?
2. How can I fix it?
3. Why would the data be saved anyways since I encountered
the SAVE RECORD ERROR?



Thanks,
Tom
 
Based on feedback in another thread, I've got the answer.

The code should be in the "BEFORE" rather than the "AFTER"
update event.

Tom
 
Back
Top