Solved

Create Dynamic Form

Posted on 2004-09-28
4
164 Views
Last Modified: 2010-05-18
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
0
Comment
Question by:MaxTo
  • 2
  • 2
4 Comments
 
LVL 28

Accepted Solution

by:
AzraSound earned 77 total points
ID: 12176749
Dim frm As Form

Set frm = Forms.Add(node.tag)
frm.Show
0
 

Author Comment

by:MaxTo
ID: 12176780
Hi AzraSound,

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
0
 

Author Comment

by:MaxTo
ID: 12176788
Hi AzraSound,
Thanks for your help....

I found the solution.


Max

0
 
LVL 28

Expert Comment

by:AzraSound
ID: 12176791
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
0

Featured Post

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question