?
Solved

Show form using variable

Posted on 2003-03-19
4
Medium Priority
?
175 Views
Last Modified: 2010-04-07
Greeting,

  In conventional way, I use

     formName.show

to show a form. I just want to know can  i declare a variable to store the form name, so later on  i can show the form depends on the value in the variable ?

If yes. How ?

Thanks for replying ......

0
Comment
Question by:PandaYong
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 22

Expert Comment

by:Mohammed Nasman
ID: 8172303
Hello

  You mean like this?

Private Sub Command1_Click()
  Dim frm As Form
  Set frm = New Form2
  frm.Show
End Sub
0
 
LVL 3

Expert Comment

by:VBtom
ID: 8172311
you ask the same question twice :(
Look at the other place you asked this question
http://www.experts-exchange.com/Programming/Q_20557035.html
0
 
LVL 5

Accepted Solution

by:
Cimperiali earned 600 total points
ID: 8172391
Dim frmX As Form
Dim strName As String
Dim bFounded As Boolean
strName = "Form1"
'look if form is already loaded
For Each frmX In Forms
   If frmX.Name = strName Then
      bFounded = True
      'already exists in forms, simply show to put it visible and focused
      frmX.Show
      'exit loop
      Exit For
   End If
Next
If Not bFounded Then
   'form is not loaded, thus add it to forms collection
   Set frmX = Forms.Add(strName)
   'now you can show it
   frmX.Show
End If
0
 

Author Comment

by:PandaYong
ID: 8172455
Thank You !
Thank You to everyone who is helping.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…
Suggested Courses

719 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