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
Printable View
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
If you are asking how to check if specific form is open then loop thru forms collection and check each name:
I let you figure out the rest on your own...Code:Dim frm As Form
For Each frm In Forms
debug.Print frm.Name
Next frm
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
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 ?
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
Ok, thank you very much
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