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!

Is Form Open? If not Open it

Status
Not open for further replies.

NormDuffy

Programmer
Jul 9, 2001
18
FR
I need to check if a form is already open. If it's not, I need to open it, otherwise carry on to the next step.
I just need to know if there is a simple way to tell if it is open.
 
Hi Norm:

Try this.


Function IsFormOpen(strForm As String) As String

Dim frm As Form
Dim Found As Boolean


For Each frm in Forms
If (frm.Name = strForm) Then
Found = True
Exit For
End If
Next frm

If (Found) Then
frm.Visible = True
Else
DoCmd.OpenForm strForm
End If


Good luck!

Ven


 
Norm,

Also,the one I always use can be found in one of the sample databases. It is called isLoaded. I import this function into EVERY db i create.

Nick
 
dear norm,
try this

If not CurrentProject.AllForms.Item("form1").IsLoaded Then

DoCmd.OpenForm "form1", acNormal
End If

regards astrid

btw. nickjar2 , what do you mean by import? It is a build-in method of the allforms collection, isn't it? ;-)
 
Sawatsky,

The isLoaded() function I thought was a function built in one of the sample dbs.

Function IsLoaded(ByVal strFormName As String) As Boolean
' Returns True if the specified form is open in Form view or Datasheet view.

Const conObjStateClosed = 0
Const conDesignView = 0

If SysCmd(acSysCmdGetObjectState, acForm, strFormName) <> conObjStateClosed Then
If Forms(strFormName).CurrentView <> conDesignView Then
IsLoaded = True
End If
End If

End Function

Nick
 
Hi Nick,

never saw that before .

thanks for Information

regards
astrid
 
All should work but I think the IsLoaded() function will suit my needs the best.

I knew I had seen the function somewhere. It is in the NorthWind sample database.

Thanks everyone for the feedback.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top