Action by popup form delayed, causing error

L

LarryP

I have a form where users select various actions. If they select option 1
(from an option group), a popup form with a combo box is supposed to open
where the user picks a value. The After Update event of the popup is
supposed to store that value in a global variable, then close itself. When I
run this process, though, my code errors out on the line FOLLOWING the
OpenForm because the global variable is still zero. (True, because although
the popup has opened, I haven't yet selected a value, buy why doesn't my code
wait for the popup to finish doing its thing before worrying about the next
line?

Here's the code, with the error-throwing line preceded by several asterisks;
the culprit in that line is intBatchPromoteGateNo, which is still zero
because the popup hasn't yet done its work. How can I force the popup
actions to run to completion BEFORE my code moves on?

Case 1:
DoCmd.OpenForm "frmBatchPromotePopup"
'Previous line opens custom input box; user selects contract, number
loads to global variable, popup closes


*****strBatchPromoteGateName = DLookup("[GateName]", "tblGates",
"[GateNo] = " & intBatchPromoteGateNo)
intBatchPromoteMinCurrentGate = DMin("[CurrentActiveGate]",
"tblContractLIData", "[ContractNo] = '" & _
Forms!frmTrackingMain!ContractNo & "' And [BatchFlag] = True")
If intBatchPromoteMinCurrentGate < intBatchPromoteGateNo - 1 Then
MsgBox ("WARNING: One or more of the flagged items has not yet
completed all the gates prior to " & _
strBatchPromoteGateName & _
". If you proceed with this batch action, any Line Items in that
category will bypass the intervening, uncompleted gates.")
End If
 
A

Allen Browne

Try being explicit about how you want the form opened:
DoCmd.OpenForm "frmBatchPromotePopup", WindowMode:=acDialog

That should cause the code to pause until the dialog form is closed.
 
L

LarryP

Great, thanks. That did it for me. I had set both Popup and Modal to yes
and thought that would do it, silly me.

Allen Browne said:
Try being explicit about how you want the form opened:
DoCmd.OpenForm "frmBatchPromotePopup", WindowMode:=acDialog

That should cause the code to pause until the dialog form is closed.

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

LarryP said:
I have a form where users select various actions. If they select option 1
(from an option group), a popup form with a combo box is supposed to open
where the user picks a value. The After Update event of the popup is
supposed to store that value in a global variable, then close itself.
When I
run this process, though, my code errors out on the line FOLLOWING the
OpenForm because the global variable is still zero. (True, because
although
the popup has opened, I haven't yet selected a value, buy why doesn't my
code
wait for the popup to finish doing its thing before worrying about the
next
line?

Here's the code, with the error-throwing line preceded by several
asterisks;
the culprit in that line is intBatchPromoteGateNo, which is still zero
because the popup hasn't yet done its work. How can I force the popup
actions to run to completion BEFORE my code moves on?

Case 1:
DoCmd.OpenForm "frmBatchPromotePopup"
'Previous line opens custom input box; user selects contract, number
loads to global variable, popup closes


*****strBatchPromoteGateName = DLookup("[GateName]", "tblGates",
"[GateNo] = " & intBatchPromoteGateNo)
intBatchPromoteMinCurrentGate = DMin("[CurrentActiveGate]",
"tblContractLIData", "[ContractNo] = '" & _
Forms!frmTrackingMain!ContractNo & "' And [BatchFlag] = True")
If intBatchPromoteMinCurrentGate < intBatchPromoteGateNo - 1 Then
MsgBox ("WARNING: One or more of the flagged items has not yet
completed all the gates prior to " & _
strBatchPromoteGateName & _
". If you proceed with this batch action, any Line Items in that
category will bypass the intervening, uncompleted gates.")
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

Top