jbakestull
asked on
Access 2007 Bound form: Close Question
I've noticed that on a data entry form (bound) if a user makes a change to text field and doesn't save the record but exits out of the form, the previous value no longer remains.
What is the best practical way to prevent a user from making changes without prompting a warning message to the user?
What is the best practical way to prevent a user from making changes without prompting a warning message to the user?
ASKER
I've never used me.dirty before.
Me. dirty = false (highlighted)
When I apply the code, rum time error message that displayed is '2115', the macro or function set to the beforeupdate or validation rule property for this feild is preventing Microsoft Office Access from saving the data in the feild.
Me. dirty = false (highlighted)
When I apply the code, rum time error message that displayed is '2115', the macro or function set to the beforeupdate or validation rule property for this feild is preventing Microsoft Office Access from saving the data in the feild.
Well, you can't set Dirty = False in the Form BeforeUpdate event ... because Me.Dirty=False is what triggers the BU event ... And Dirty will already be True in the BU event.
I'm sure Capricorn1 meant a different event ...
I'm sure Capricorn1 meant a different event ...
sorry about that, try this revision
private sub form_beforeupdate(cancel as integer)
if me.dirty then
if (msgbox ("do you want to save changes made ?",vbyesno))=vbyes then
else
me.undo
cancel=true
end if
end if
end sub
private sub form_beforeupdate(cancel as integer)
if me.dirty then
if (msgbox ("do you want to save changes made ?",vbyesno))=vbyes then
else
me.undo
cancel=true
end if
end if
end sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Apply dirty in before event wasn't the best logical choice.
private sub form_beforeupdate(cancel as integer)
if me.dirty then
if (msgbox ("do you want to save changes made ?",vbyesno))=vbyes then
me.dirty=false
else
me.undo
cancel=true
end if
end if
end sub