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

Forms Currently Open 3

Status
Not open for further replies.

sucoyant

IS-IT--Management
Sep 21, 2002
213
US
Good day all!

Is there a way that I can programatically get the name of the forms that are currently open in a database?

Thanks!

________________________________________
BUDDHA.gif
Buddha. Dharma. Sangha.
 
You could try this function:
Code:
Function IsItOpen(strFormName As String) As Boolean
Dim frm As Form

For Each frm In Forms
    If frm.Name = strFormName Then
        IsItOpen = True
    End If
Next frm

End Function

Then, in your code, just do this:
if isitopen("Time3") then


HTH
Mike

[noevil]
 
Hi Sucoyant,

Here is the code that I use that tells you if a specific form is open, with a little modification (I'm not doing it all for you ;0) ) it'll give what you need.

Public Function IsFormOpen(frm_name As String) As Boolean
On Error GoTo Err_Function
Dim line As Integer
Dim dbs As DAO.Database
Dim r1, r2, r3 As DAO.Recordset
Dim q1, q2, q3 As String

Dim frm As Form

IsFormOpen = False

For Each frm In Forms
If frm.Name = frm_name Then
IsFormOpen = True
End If
Next

Exit_Function:
Set r3 = Nothing
Set r2 = Nothing
Set r1 = Nothing
Set dbs = Nothing
Exit Function

Err_Function:
MsgBox Err.Description, , "Is Form Open Line " + str(line)
IsFormOpen = False
Resume Exit_Function
End Function

Hope it helps,

Jes
 
You will need to step through the Forms Collection to get the list of currently opened forms.

Sub AllForms()
Dim obj As AccessObject, dbs As Object
Set dbs = Application.CurrentProject
' Search for open AccessObject objects in AllForms collection.
For Each obj In dbs.AllForms
If obj.IsLoaded = True Then
' Print name of obj.
Debug.Print obj.Name
End If
Next obj
End Sub


HTH,

Steve
 
Wow... thanks to all of you!!

Excellent help.

________________________________________
BUDDHA.gif
Buddha. Dharma. Sangha.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top