does anybody know, how i can modify data in the current record set of a form by vb code BEFORE the user has started editing any of the form fields?
because in this case usually the form or record set is not in editing mode and the trial to modify a field value or form field value by code will either result in an error message or even in a crash of the whole access application ("MS Access has encountered a problem...", you know the ...)
in other words: is there a way of switching a record to editing mode before the user has done any action in the form?
to be more presize:
sql server 2000 backend
datasource of the form is the table, not a stored procedure
letīs say the user only views a record in my form, does NO editing at all
now before leaving the record i want to save the current date and time in a column of this record called "LastViewed":
me!LastViewed = now
will lead to an error or even access application crash
and i donīt know why.
i guess itīs because the user hasnīt edited the record at all and the form is NOT in sort of an editing mode, but how can i move into this mode?
I guess I misunderstood your original question. I have an uncanny
knack for stating the obvious!
Are you saying that you want your code to take one action if the user
views a record, but does not edit it; and a different action if the user
edits the form?
Since Access doesn't have a OnLeaveRecord event (kinda like the opposite of OnCurrent) I build my own buttons to move through the
recordset, and turn off the navigation buttons. That way I can do things
If Me.Dirty then
If Me.Newrecord then
That allows you to test what the user entered, or make changes to data,
before moving on to the next record.