Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Other Form open

Status
Not open for further replies.

hblabonte

Programmer
Oct 3, 2001
84
US
How can I tell if another form is open with VBA?

I'm in Form A and want to in my code, check to see if Form B is also open.

Anyone?

Thanks!
 
Check out Rohdems faq faq181-320

[tt]if isloaded("frmB") then[/tt]

Roy-Vidar
 
Hmm, I'm getting an error with that. I'm in access 2003.

I just tried this:

If Forms!groupdetails_frm.IsLoaded = True Then

but since that form (groupdetails) is not open, I get an error that it can not find the form referred to in the code.
 
The name of the form goes as parameters to the function. In my above sample, I used the name "frmB". If the name of your form is "GroupDetails" then

[tt]if isloaded("GroupDetails") then
' bla bla
end if[/tt]

Roy-Vidar
 
In that case, I get a compile error stating that the sub or function is not defined.

???
 
Where did you place the function from the faq, it needs to be in a module, not a forms/reports module.

Roy-Vidar
 
It's connected to a combo box on a form. That's when I need to peform the steps to follow after the check. Are you saying that's not doable? ugh.
 
Eh - I'll repeat the question (including some more words) where did you paste the function which you (should have) copied from the link I provided in my first reply. It needs to go within a new module, not a forms or reports module.

Roy-Vidar
 
Sorry if I'm not understanding your question... I don't usually program in Access.

On my form, I have a combo box. After update, the following code takes place.

Private Sub Combo4_AfterUpdate()

Dim cur_group As String ' group in drop down.
Dim msg As String


If IsLoaded(groupdetails_frm) Then
'If Forms!groupdetails_frm.IsLoaded = True Then

blah blah....

End If

End Sub
 
Copy/paste?
[ol][li]click the link I gave in first reply[/li]
[li]select the text (the complete isloaded function), then COPY[/li]
[li]select Access again[/li]
[li]enter VBE, in the Insert menu, select Module[/li]
[li]in the new module PASTE the contents of the faq[/li]
[li]SAVE the new module[/li]
[li]call it like I've demonstrated a couple of times, including the quotes around the name[/li][/ol]

Roy-Vidar
 
Ah ha! I missed that in your first post. Thank you for your help!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top