Don't run is new record

  • Thread starter Thread starter lynne
  • Start date Start date
L

lynne

I'm having a problem with users accidently changing a
field on my form. So I added code to On Change of that
field that pops up a msg box that asks if they really
want to change. Yes will continue - No will undo. The
problem is it pops up on new records as well. How can I
have it check if its a new record before it does the
popup?

TIA,
Lynne
 
You can test the NewRecord property of the form:

if not me.newrecord then
'warn user
endif

I prefer to "lock" controls like this by setting the locked property of the
control to true, changing the background color of the control to match the
background of the form (visual clue to user) then add an edit button next to
the control which when clicked, Unlocks the control by setting it's Locked
property to false.

Then relock the control in the AfterUpdate event and in the Current event of
the form unless the record is a new record (testing the NewRecord property)
in which case it would need to be unlocked.

IMHO this is a little more user friendly and still safegaurds the data in a
field which shouldn't be changed inadvertantly.
 
Back
Top