How to make code wait for form to close

Archie999

Access Wannabee
Local time
Today, 13:27
Joined
May 25, 2003
Messages
45
Hello again all,

I have a form with a combobox. The combobox has a Not In List event that triggers another form to get info from user and to add a new record (and hence a new item to the list). This works fine.

What I would like is to have a dialog box pop up and ask the user if they would like to add optional information to a different table. But this dialog box needs to pop up only AFTER they have finished entering info into the first form and hit OK to close it.

What is happening now is that my data entry form pops up and then my dialog question box pops up at the same time. How can I make the code wait. I thought the 'acDialog' option was supposed to do this but it does not seem to work.

My first pop up form is modal, as is the dialouge question box.

Here is the pertinent code. Thanks very much, in advance for you help!!

'Confirm user would like to add a new site

If vbNo = MsgBox("Add new Site?", vbYesNo + vbQuestion, _
"Site not found") Then

Response = acDataErrContinue
Exit Sub
End If

DoCmd.OpenForm "frmSite", acNormal, , , acAdd, acDialog, NewData

' The code should wait until the first dialog box is closed and then continue
' Ask user if they would like to add site contacts

If vbNo = MsgBox("Would you like to add site contacts?", vbYesNo + vbQuestion, _
"Add Site Contacts?") Then

Response = acDataErrAdded
Exit Sub
End If

DoCmd.OpenForm "frmSiteContact", acNormal, , , acAdd, acDialog
Response = acDataErrAdded
 
If vbNo = MsgBox("Would you like to add site contacts?", vbYesNo + vbQuestion, _
"Add Site Contacts?") Then

Response = acDataErrAdded
Exit Sub
End If

DoCmd.OpenForm "frmSiteContact", acNormal, , , acAdd, acDialog
Response = acDataErrAdded

Couldn't you put this code in the OnClose event of the first form?
 

Users who are viewing this thread

Back
Top Bottom