Macro execution

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a data entry form that contains a checkbox, currently the macro executes as soon as the box is checked . I would like the macro to execute when the save record button is clicked is there a way to attach this macro to the automatically generated buttos on the form or is there a workaround that I am not aware of.
 
i take it that the Save button has an event procedure on it that was written
by the wizard? code looks something like this (different number at end of
"Command", of course)?

Private Sub Command51_Click()
On Error GoTo Err_Command51_Click


DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70

Exit_Command51_Click:
Exit Sub

Err_Command51_Click:
MsgBox Err.Description
Resume Exit_Command51_Click

End Sub

you can add the following line of code, either before or after the DoCmd
line(s), as
DoCmd.RunMacro "MyMacroName"

substituting the name of your macro for MyMacroName, of course.

hth


Klutzz said:
I have a data entry form that contains a checkbox, currently the macro
executes as soon as the box is checked . I would like the macro to execute
when the save record button is clicked is there a way to attach this macro
to the automatically generated buttos on the form or is there a workaround
that I am not aware of.
 
Back
Top