MaxTo
asked on
Create Dynamic Form
Hi all Experts,
I got a project, i used the tree view to be the menu, In the nodes i store the "form name" from database into the node.tag.
So when i click on the node, i return the tag, so i know which form to be call.
Example i got three form name
frmabout, frmLogin, frmHow
for the easy way is
if node.tag = "frmabout" then frmabout.show
if node.tag = "frmLogin" then frmLogin.show
if node.tag = "frmHow" then frmHow.show
if i got 100 form then i need to write 100 statements...
so can i combine allstatement to one? Just dynamic the code to be used to calling all forms.
Thanks....
Max
I got a project, i used the tree view to be the menu, In the nodes i store the "form name" from database into the node.tag.
So when i click on the node, i return the tag, so i know which form to be call.
Example i got three form name
frmabout, frmLogin, frmHow
for the easy way is
if node.tag = "frmabout" then frmabout.show
if node.tag = "frmLogin" then frmLogin.show
if node.tag = "frmHow" then frmHow.show
if i got 100 form then i need to write 100 statements...
so can i combine allstatement to one? Just dynamic the code to be used to calling all forms.
Thanks....
Max
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi AzraSound,
Thanks for your help....
I found the solution.
Max
Thanks for your help....
I found the solution.
Max
Public Function GetOpenForm(ByVal FormName As String) As Form
Dim frm As Form
For Each frm In Forms
If frm.Name = FormName Then
Set GetOpenForm = frm
Exit Function
End If
Next
End Function
Dim frm As Form
Set frm = GetOpenForm(node.tag)
If frm Is Nothing Then
Set frm = Forms.Add(node.tag)
End If
frm.Show
Dim frm As Form
For Each frm In Forms
If frm.Name = FormName Then
Set GetOpenForm = frm
Exit Function
End If
Next
End Function
Dim frm As Form
Set frm = GetOpenForm(node.tag)
If frm Is Nothing Then
Set frm = Forms.Add(node.tag)
End If
frm.Show
ASKER
The function u privide is work, but it will appear more than one form for the particular form, how i can make it just show one, and if it was open and not active then how i can make it to be active form?
Thanks..
Max