Copilot for Microsoft 365 Tech Accelerator
Feb 28 2024 07:00 AM - Feb 29 2024 10:30 AM (PST)
Microsoft Tech Community
SOLVED

Open Form acDialog

Steel Contributor

 

 

Hello Experts,

I have the below code firing on my main form.

When the main form opens, the other forms in teh code open if Dcount>0.

I have noticed that the forms open all at once and not one at a time. 

I want 1 form to open then click close then the next form opens...not all at once. 

I thought that WindowMode:=acDialog is what I need? 

 

thank you
Private Sub Form_Load()

If DCount("*", "qryNotifications") > 0 Then

DoCmd.OpenForm "frmNotifications", WindowMode:=acDialog

End If

If DCount("*", "qryNotificationsDateChecks") > 0 Then

DoCmd.OpenForm "frmNotificationsDateCheck", acFormDS, WindowMode:=acDialog

End If

If DCount("*", "qryNotificationsLC") > 0 Then

DoCmd.OpenForm "frmNotificationsLC", WindowMode:=acDialog

End If

End Sub

6 Replies

@Tony2021 

How about putting each succeeding Form open event on the close event of the previous form?  

that is a good idea. I didnt think of that. I would prefer to have all the code in the main form though.
Agreed, but sometimes plan B works when plan A, which would be more elegant doesn't.

I will take a look tomorrow, but I'm not confident you can control the opening of the downstream forms that way, although I agree that opening a form with the dialog mode is supposed to suspend processing of subsequent.
OK. FYI: I do have the forms as pop up and modal. Let me know if you have any other ideas. thank you
best response confirmed by Tony2021 (Steel Contributor)
Solution

actually there are Errors in your code!
did you disable error checking?

see your sample:

DoCmd.OpenForm "frmNotifications", WindowMode:=acDialog

did you noticed what is wrong?
if not then, here you define WindowMode:=acDialog, but, did you define the FormName?

should be:

DoCmd.OpenForm FormName:="frmNotifications", WindowMode:=acDialog

 

for the acFormDS form:

 

DoCmd.OpenForm FormName:="frmNotificationsDateCheck", View:=acFormDS, WindowMode:=acDialog


do it with the rest of your code.

Arnel, that did it. Perfect. thank you again for the help!
1 best response

Accepted Solutions
best response confirmed by Tony2021 (Steel Contributor)
Solution

actually there are Errors in your code!
did you disable error checking?

see your sample:

DoCmd.OpenForm "frmNotifications", WindowMode:=acDialog

did you noticed what is wrong?
if not then, here you define WindowMode:=acDialog, but, did you define the FormName?

should be:

DoCmd.OpenForm FormName:="frmNotifications", WindowMode:=acDialog

 

for the acFormDS form:

 

DoCmd.OpenForm FormName:="frmNotificationsDateCheck", View:=acFormDS, WindowMode:=acDialog


do it with the rest of your code.

View solution in original post