shinfotec
asked on
Open form by its name
how can i open unloaded VBForm by its name like:
forms.("FormName").show .... or any way
forms.("FormName").show .... or any way
Or if you meant where you have the name as a string you could try this
' Add the form to the forms collection
Forms.Add "FormName"
' Show the form with the highest index (which is the last added and in this case FormName)
Forms(Forms.Count - 1).Show
Cheers
Scott
' Add the form to the forms collection
Forms.Add "FormName"
' Show the form with the highest index (which is the last added and in this case FormName)
Forms(Forms.Count - 1).Show
Cheers
Scott
Or do you not want to 'hard-code' the form name (is it, perhaps, stored within a string)?
If so, try:
Sub OpenFormByName(ByVal sFormName As String)
Dim frm As VB.Form
For Each frm In Forms
If frm.Name = sFormName Then frm.Visible = True
Next frm
End Sub
Now just open the form, with
OpenFormByName("myFormName ")
Although, you will have to have loaded all forms beforehand, in an initialisation routine, as Forms collection only contains the loaded forms.
HTH
J.
If so, try:
Sub OpenFormByName(ByVal sFormName As String)
Dim frm As VB.Form
For Each frm In Forms
If frm.Name = sFormName Then frm.Visible = True
Next frm
End Sub
Now just open the form, with
OpenFormByName("myFormName
Although, you will have to have loaded all forms beforehand, in an initialisation routine, as Forms collection only contains the loaded forms.
HTH
J.
Dim myFormName As String, NewForm as Form
'to show the form
myFormName = "Your form name"
Forms.Add (myFormName)
Set NewForm = Forms(Forms.Count - 1)
NewForm.Show
'and when you unload the "NewForm" add this line to your code
Set NewForm = Nothing
S
'to show the form
myFormName = "Your form name"
Forms.Add (myFormName)
Set NewForm = Forms(Forms.Count - 1)
NewForm.Show
'and when you unload the "NewForm" add this line to your code
Set NewForm = Nothing
S
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Dim frm As Form
For Each frm In Forms
If frm.Name = "myLoadedForm" Then
frm.Show vbModal
End If
Next
This depends on the form already being loaded
For Each frm In Forms
If frm.Name = "myLoadedForm" Then
frm.Show vbModal
End If
Next
This depends on the form already being loaded
how about
FormName.Show
Scott