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 strongm 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 already open

Status
Not open for further replies.

Marty2of5

Programmer
Apr 23, 2001
11
US
Hi, I'm not too familiar with ADO and I keep getting error messages trying to do this how I think it will work.

I have a control on a form (frmMain) that runs some automation before opening another form (frmAssign). However, if the frmAssign is already open, I don't want to run the automation -- I just want it to change the focus to frmAssign.

What is the simplest way to run that conditional?

Thanks,

Marty
 
One way you might try is to find the form in the Application.CurrentProject.AllForms collection and then check the .IsLoaded property.
Code:
Dim TheObj              As AccessObject
For Each TheObj In Application.CurrentProject.AllForms
   If (TheObj.Name = "frmAssign") Then
      If (TheObj.IsLoaded = True) Then
         Skip the Automation
      Else
         Perform the Automation
      Endif
   End if
Next TheObj

Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
 
Hi!

If there's a possibility that the form might be open in design view, Rohdem's "IsLoaded" function in faq faq181-320 might be a good alternative.

[tt]If IsLoaded("frmAssign") then
' do the automation
else
' set the focus
end if[/tt]

You'll need to copy/paste his code into a module (not a forms module)

Roy-Vidar
 
The users will not have access to design view. CajunCenturion's solution is working. It would be great to use Rohdem's function if this comes up multiple times.

Thanks again!
Marty
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top