• Check if a form is already open using macro (2000)

    Home » Forums » AskWoody support » Productivity software by function » MS Access and database help » Check if a form is already open using macro (2000)

    Author
    Topic
    #383604

    I have a macro which runs 4 reports. Each of the reports, when run individually starts by opening a form to allow the user to enter some criteria. Each report uses the same form (called imaginatively form1). In the macro which combines them, the form is displayed as each form opens. Is there macro condition which I can enter to check if the form is already open? If it is open I want skip the openform line in the macro.
    John

    Viewing 2 reply threads
    Author
    Replies
    • #654746

      Is the form (form1) closed when the first ‘results’ form is opened? if so why is the form closed after the first form has opened?

      Do the forms all run off queries pointed at form1? I’m guessing they do.

      If so, opening form1, requesting the criteria and then keeping form1 open in the background (minimised??) would allow the subsequent queries to get the criteria without repeatedly asking for it.

      I may be considering this too simplistically, but this is what I’ve done under similar circumstances.

      Ian

    • #654747

      You can put the following function in a standard module:

      Function IsLoaded(ByVal strFormName As String) As Boolean
      ‘ Returns True if the form is loaded
      If SysCmd(acSysCmdGetObjectState, acForm, strFormName) Then
      IsLoaded = Forms(strFormName).CurrentView
      End If
      End Function

      Call it like this in code

      If IsLoaded(“Form1”) Then

      Else

      End If

      or use it as a condition in a macro.

      • #654767

        You can also use this in Access 2000 and 2002:

        If CurrentProject.AllForms(strFormName).IsLoaded = True then ...
    • #655024

      thanks all for your help – i’ve pieced together enough to sort the problem from your replies

    Viewing 2 reply threads
    Reply To: Check if a form is already open using macro (2000)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: