Avatar of TerenceHewett
TerenceHewett
 asked on

How do I undo a field on a form using VBA?

Hi experts,

I have a form called "Setup" and fields on the form.  One of these fields is called "DateFormat".  It is a combo box.  The format is either DD/MM/YYYY or MM/DD/YYYY.  When the user selects one of these options, and then clicks the "save" button, a msgbox pops up that states that the system needs to log off for these changes to take effect. Do you want to do this now? Yes/No.  

If the user selects "Yes" the system logs off with no problems.


If the user selects "No" then I need the DateFormat field to undo the last selection.  So if prior to selecting something from the DateFormat field the data showed "DD/MM/YYYY" and now the user has changed that to "MM/DD/YYYY", I would like to undo the last change and revert back to "DD/MM/YYYY".  I have tried the attached code in the "No" button of the msgbox, but nothing is working. Can anybody help?

Thank you.
Terry
Forms![Setup]![DateFormat].Undo

and 

Forms![Setup]![DateFormat] = Forms![Setup]![DateFormat].OldValue

Open in new window

Microsoft Access

Avatar of undefined
Last Comment
TerenceHewett

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Rey Obrero (Capricorn1)

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
TerenceHewett

ASKER
Cap - as always - your solution was perfect.

Regards
Terry
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck