execute code after pop-up form closes

  • Follow


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 


0
Reply Mark 2/17/2010 12:57:09 AM

Why not put the DeleteCatalogBaseSheets and AddCatalogBaseSheets to
the Open event of "FixtureCatalogesPages"?
0
Reply Piet 2/17/2010 1:18:37 AM


"Mark Kubicki" <Mark@TillotsonDesign.com> wrote in message 
news:OYtGdw2rKHA.5568@TK2MSFTNGP05.phx.gbl...
>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).


0
Reply Stuart 2/17/2010 1:22:19 AM

2 Replies
549 Views

(page loaded in 0.201 seconds)

Similiar Articles:













8/1/2012 7:51:18 AM


Reply: