Full Version: Look at all open forms
UtterAccess Forums > Microsoft® Access > Access Forms
recall
Can someone please advise me how (with code) I can look through all currently open forms in my database and check if one exists with a caption of "Test" for example.
Thanks for any help offered,
Richard.
Bob_L
Here you go.

CODE
Function TestForm(strCaption As String) As Boolean
nbsp;   Dim frm As Form
    Dim blnExists As Boolean
    For Each frm In Application.Forms
        If CurrentProject.AllForms(frm).IsLoaded Then
            If frm.Caption = strCaption Then
                blnExists = True
            End If
        End If
    Next frm
    TestForm = blnExists
End Function
vtd
CODE
Function fnTestForm(strCaption As String) As Boolean
  
  Dim frm As Form

  For Each frm In Forms
    If frm.Caption = strCaption Then
      fnTestForm = True
      Exit Function
    End If
  Next frm
  
  ' If the code gets to here, none of the open Forms has the Caption strCaption
  fnTestForm = False
End Function
This is a "lo-fi" version of UA. To view the full version with more information, formatting and images, please click here.