"After Update" newbie problem

Johnrg

Registered User.
Local time
Today, 18:16
Joined
Sep 25, 2008
Messages
115
Guys and Gals,

I want to add an event procedure to a feild in a from so that if the data is changed a yes/no system message appears asking the user if they are sure they want to change the data in the feild.

If they click yes the change is accepted if they click no the feild reverts to back to its original data.

I have used this code and I get the system message OK but if I click "No" the data remains changed and does not revert back to the original value.

Code:
Private Sub Pack_Number_AfterUpdate()
 
If MsgBox("Are you sure you want to CHANGE this Number?", vbQuestion + vbYesNo, "System Message") = vbNo Then Exit Sub

Could someone poit me in the right direction?

Thanks

JohnG
 
Ah!, thank you!
JG
 
Last edited:
Guys,
Still having an issue with this code.
If I change data in the feild and then hit enter or move the focus to another feild I get the system message prompt OK but if I select the "NO" option the data still remains changed.

I want selecting NO to revert the data back to its original form.

I think the code is missing something but not sure what.
Thanks
JohnG
 
You are probably missing an Undo. It would help to see your code.
 
Here it is:


Code:
Private Sub Pack_Number_BeforeUpdate()

If MsgBox("Are you sure you want to CHANGE this Number?", vbQuestion + vbYesNo, "System Message") = vbNo Then Exit Sub
 
Did you miss the use of "Cancel = True" in the sample code? It sounds like you'd also want an Undo on the control.
 
One other thing (I know Paul, you don't like it when I add info to your threads) -

This is not a valid event header:

Private Sub Pack_Number_BeforeUpdate()

It is obviously typed in as it should be:

Private Sub Pack_Number_BeforeUpdate(Cancel As Integer)
 
Thanks for your input guys.
To be honest I am lost here, I know nothing about VBA code, I copied this code from another part of the DB and am trying to learn as I go. (steep curve!)
I have no idea what an undo is!
I tried the sample code but it threw up a compile error.
I put in Cancel=True as a new line but got another error.
Help?
JG
 

Users who are viewing this thread

Back
Top Bottom