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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Determine If A Form Is Loaded

Status
Not open for further replies.

cnealy

Programmer
Feb 25, 2002
32
US
I have an MDI application. At times, I need to make a call to a form only if the form is loaded.

So, for instance, I might have a line of code on frm1 that says:

With frm2.Adodc1
.commandtype = blah
.Recordsource = blah
.refresh
End With

There are two problems:

I only need to perform this refresh if frm2 is loaded. And, when I execute this code, frm1 loses focus, but I don't want that to happen.

Any ideas/suggestions on how to handle this? This is an issue throughout my application.
 
Use the Forms collection.

Loop through the Forms collection looking at the .Name property for the form that might be loaded. If you find it, it's loaded.
 
Dim frmVar As Form

For Each frmVar In Forms
If frmVar.Name = "your form name" Then
MsgBox "found form"
End If
Next
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top