execute code after pop-up form closes

M

Mark Kubicki

I have this code (below) which opens a pop-up form and then after the form
is closed should run 2 sub-routines followed by a requery of the current
form; however, what seems to be happening is that the subs and requery
happen as soonas the form is opened and not when it is closed...
I can see how this makes sense, since afterall, it is doing what I am
telling it to do (open the form and then do something else); but this is not
how I need it to behave...
My hunch is that i need to move the subs and requery to the close event on
the pop-up?

Any suggestions would be greatly appreciated,

(the 2 subs are used elsewhere in the project, and i would rather not modify
them -but if I have to, i would...)

many thanks in advance,
mark


Private Sub cmdAddCutsToMaster_Click()
On Error GoTo Err_cmdAddCutsToMaster_Click
Dim stDocName As String
Dim stLinkCriteria As String
strOpenArgs = "true" & "~" & Me![Manufacturer] & "~" & Me![CatalogNo]

strDocName = "FixtureCatalogesPages"
strLinkCriteria = "[Manufacturer] = '" & Me.Manufacturer & "' AND
[CatalogNumber] = '" & Me.CatalogNo & "'"

DoCmd.OpenForm strDocName, , , strLinkCriteria, , , strOpenArgs

Call DoSQLDeleteCatalogBaseSheets(Me)
Call DoSQLAddCatalogBaseSheets(Me)
Forms![frmSpec].chldFixtureCuts.Requery
 
P

Piet Linden

Why not put the DeleteCatalogBaseSheets and AddCatalogBaseSheets to
the Open event of "FixtureCatalogesPages"?
 
S

Stuart McCall

Mark Kubicki said:
I have this code (below) which opens a pop-up form and then after the form
is closed should run 2 sub-routines followed by a requery of the current
form; however, what seems to be happening is that the subs and requery
happen as soonas the form is opened and not when it is closed...
I can see how this makes sense, since afterall, it is doing what I am
telling it to do (open the form and then do something else); but this is
not how I need it to behave...
My hunch is that i need to move the subs and requery to the close event on
the pop-up?

Any suggestions would be greatly appreciated,

(the 2 subs are used elsewhere in the project, and i would rather not
modify them -but if I have to, i would...)

many thanks in advance,
mark


Private Sub cmdAddCutsToMaster_Click()
On Error GoTo Err_cmdAddCutsToMaster_Click
Dim stDocName As String
Dim stLinkCriteria As String
strOpenArgs = "true" & "~" & Me![Manufacturer] & "~" & Me![CatalogNo]

strDocName = "FixtureCatalogesPages"
strLinkCriteria = "[Manufacturer] = '" & Me.Manufacturer & "' AND
[CatalogNumber] = '" & Me.CatalogNo & "'"

DoCmd.OpenForm strDocName, , , strLinkCriteria, , , strOpenArgs

Call DoSQLDeleteCatalogBaseSheets(Me)
Call DoSQLAddCatalogBaseSheets(Me)
Forms![frmSpec].chldFixtureCuts.Requery

You need to specify that the form is a modal dialog by passing acDialog in
the WindowMode parameter, ie:

DoCmd.OpenForm strDocName, , , strLinkCriteria, , acDialog, strOpenArgs

This instructs Access to only start executing the following lines of code
when the dialog form either closes or is made invisible (Me.Visible = True).
 

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

Top