Stop Macro On Close Event

G

Guest

I have a form, frmAssign, that I can access two ways. When I close the form a
macro runs from the On Close Event. The macro up dates another form,
frmPlanResources.
If I have accessed frmAssign from the main switchboard and then close it I
don’t want the macro to run. However if I access frmAssign from another form,
frmPlanResources I would like the macro to run.
I use a close form button to close the frmAssign and the On Close Event is
below.

All help is appreciated.
Regards
Nick



Private Sub Form_Close()
On Error GoTo Err_Command19_Click

Dim stDocName As String

stDocName = "mcrPlanResources"
DoCmd.RunMacro stDocName

[Forms]![frmPlanResources].Requery

Exit_Command19_Click:
Exit Sub

Err_Command19_Click:
MsgBox Err.Description
Resume Exit_Command19_Click
End Sub
 
G

Guest

Pass an indication using the OpenArgs in the Open form command line when you
want the macro to run, and when not to run it.

Docmd.OpenForm "FormName" , , , , , , "RunMacro"


Before you run the macro you can add a criteria

If Me.OpenArgs = "RunMacro" Then
Run macro here
End If
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top