Cancel Record Change

B

Brad

Thanks for taking the time to read my question.

I have a form where the controls are Enabled = False. For the user to edit
the records they have to click a button which makes a copy of the record and
the form moves to the record. So if the user doesn't edit the record it would
be a duplicate so I need to manage that. I check to see if they have edited
the message at the OnCurrent event and if not I ask them if they would like
to stay on the record or not. If they say 'Yes', then I need to go back to
the record they just left, or stop them from leaving. If I step through the
code and watch my form, the record changes first then the OnCurrent Event
fires. I can't catch it on the BeforeUpdate event becuase no data has changed.

I'm doing this becuase I need to keep all historical data. My DB is on cell
phone info, so if the contract changes I need to see the old one and the new
one. If the owner changes I need to see the old one and the new one etc...

Thanks for your help.

Brad
 
A

Arvin Meyer [MVP]

Change the way you are copying the record. Instead of disabling the
controls, leave them enabled and use the before update event to copy the
record's OldValue property to a new record. Here's a code snippet, obviously
you need to dim all the variables:

lngItemID = Me.txtItemID.OldValue
strSubdivision = Me.txtSubdivision.OldValue
dblCost = Me.txtCost.OldValue

strSQL = "INSERT INTO tblItemHistory ( ItemID, Subdivision, Cost )"
strSQL = strSQL & " VALUES (" & lngItemID & ", '" &
strSubdivision & "', " & dblCost & "');"
db.Execute strSQL

The BeforeUpdate event won't fire it a copy isn't required and will
automatically make the copy if the record is altered.
 

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