Results 1 to 7 of 7

Thread: How many test form is open?

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2008
    Posts
    446

    How many test form is open?

    I suppose there are many programs of the form, I can determine how much the order form is opened and the name of the form is not open? Who can share me with example

  2. #2
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,135

    Re: How many test form is open?

    If you are asking how to check if specific form is open then loop thru forms collection and check each name:
    Code:
    Dim frm As Form
    
    For Each frm In Forms
        debug.Print frm.Name
    Next frm
    I let you figure out the rest on your own...

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2008
    Posts
    446

    Re: How many test form is open?

    1. form that is open can have a number of these?

    2. closed form series open with error
    For Each frm In Forms
    If frm.Name <> Me.Name Then
    If frm.MDIChild = True Then
    MDIMainForm.RemoveChild frm.Name ' Error here
    End If
    End If
    Next
    Set frm = Nothing

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2008
    Posts
    446

    Re: How many test form is open?

    if I use Unload the following Unload I have must to put the correct name of FormChild. eg MDIForm have Form1, Form2, ... Formn:

    Unload Form1
    Unload Form2
    ...
    Unload Formn


    Now, I want to replace the code above with:

    Dim frm As Form
    ' Close many FormRemoveChild
    For Each frm In Forms
    If Me.Name <> frm.Name Then ' Me.Name is MDIForm and frm.Name is Form1, Form2, ...., Formn
    Unload frm.Name ' Error here
    End If
    Next
    Set frm = Nothing

    What should I do ?

  5. #5
    Default Member Bonnie West's Avatar
    Join Date
    Jun 2012
    Location
    InIDE
    Posts
    4,057

    Re: How many test form is open?

    The Unload statement expects an Object (a Form or a Control), not a String. Try this instead:

    Code:
    Private Sub mnuCloseAllMDIChildForms_Click()
        Do Until Me.ActiveForm Is Nothing
            Unload Me.ActiveForm
        Loop
    End Sub
    Last edited by Bonnie West; Aug 15th, 2013 at 04:25 AM.
    On Local Error Resume Next: If Not Empty Is Nothing Then Do While Null: ReDim i(True To False) As Currency: Loop: Else Debug.Assert CCur(CLng(CInt(CBool(False Imp True Xor False Eqv True)))): Stop: On Local Error GoTo 0
    Declare Sub CrashVB Lib "msvbvm60" (Optional DontPassMe As Any)

  6. #6

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2008
    Posts
    446

    Re: How many test form is open?

    Ok, thank you very much

  7. #7
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    13,293

    Re: How many test form is open?

    This question was answered already on Code Guru. Did you even try what I showed you?

    Basically you do not use the name you use the object as shown here in Red
    Code:
    For Each frm In Forms
        If frm.Name <> Me.Name Then
            If frm.MDIChild = True Then
                Unload frm
            End If
        End If
    Next
    Set frm = Nothing

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width