Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Autokeys macro problem

Status
Not open for further replies.

shb46

Programmer
Jul 11, 2001
10
0
0
GB
I have created the AutoKeys macro for function key F1 which when pressed closes the current form and opens a Main Menu form. On the close form line of the macro I have specified Save = No and yet any changes made to the form are saved. Can anyone help please?

Many Thanks
Sue
 
By "changes in the form", are you referring to values in the form's controls? If so, you have a misunderstanding. The Save parameter on Close refers to changes in the design of the form, not to changes in the record displayed on the form. Any record changes are always saved when you close the form.

If that's your problem, you can probably fix it by adding two lines to the macro before the Close action. In both lines, use the following macro parameters:
Code:
    Condition: Forms![<formname>].Dirty
    Action:    RunCommand
    Command:   Undo
You need to do the Undo twice, because the first one may only back out changes to the current field. The second one will then back out the rest of the fields. If the current field wasn't changed, but another field was, the first Undo will back out all the fields, and the second Undo will be skipped by the condition. If no fields were changed, both Undos will be skipped, but no record save will occur anyway because there were no changes. Rick Sprague
 
Thanks for that. I had to add three lines to the macro not two to get it to work properly.

Condition: [Screen].[activeform].[Dirty]=True
Action: RunCommand
Command: Undo

Sue
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top