Link to home
Start Free TrialLog in
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

ASKER CERTIFIED SOLUTION
Avatar of Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of TerenceHewett
TerenceHewett

ASKER

Cap - as always - your solution was perfect.

Regards
Terry