Access VBA Simple "undo" question

See my VBA which does a msgbox "beforeupdate".
Question: If I click "cancel" in the msgbox WHY does it NOT undo the change I made to the control IFGYesNocmb.  Do I need to do some thing else??

Private Sub IFGYesNocmb_BeforeUpdate(Cancel As Integer)
If MsgBox("Confirm This Change to IFG Status", vbOKCancel, _
    "OK Or Cancel") <> vbOK Then
    Me.IFGYesNocmb.Undo
    Exit Sub
End If

End Sub

Open in new window

Patrick O'DeaAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
Try this:

If MsgBox("Confirm This Change to IFG Status", vbOKCancel, _
    "OK Or Cancel") <> vbOK Then
    Me.IFGYesNocmb.Undo
    Cancel = True
End If
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Dale FyeOwner, Developing Solutions LLCCommented:
No points please.

I think you can remove the UNDO line and simply use Scott's line:

If MsgBox("Confirm This Change to IFG Status", vbOKCancel, _
    "OK Or Cancel") <> vbOK Then
    Cancel = True
End If
0
PatHartmanCommented:
Both lines are necessary if you want to back out the change as well as cancel the update.

"Cancel = True", cancels the control/record save but does not alter the "new" value

Me.somefield.Undo, backs out the change to the specified control and resets the control to the original value.
Me.Undo, backs out the change to the current record and resets all controls to their original values.
0
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

Patrick O'DeaAuthor Commented:
folks, I tried the "Cancel=True" but no joy.
See attached frmMain.   Perhaps because it is a "combo" or perhaps the continuous form causes a complication.

See 20 second video
http://screencast.com/t/lii9Pl7LDwyT
IFG1.accdb
0
Patrick O'DeaAuthor Commented:
Thanks Pat,

That's it!
0
Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
I don't quite follow. Seems my code was the solution, with Pat's explanation being followup, so I'm not clear on the point award. Can you please explain why you awarded points in that manner?
0
Patrick O'DeaAuthor Commented:
Sorry Scott , I mis read the comments.

How can I re-allocate points?
0
Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
You can ask the Mods to reopen the question. Just use the Request Attention link at the top of your question, just below the original text.
0
Patrick O'DeaAuthor Commented:
Thanks,
All working well.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.