Show form using variable

Posted on 2003-03-19
Medium Priority
Last Modified: 2010-04-07

  In conventional way, I use


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 ......

Question by:PandaYong
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
LVL 22

Expert Comment

by:Mohammed Nasman
ID: 8172303

  You mean like this?

Private Sub Command1_Click()
  Dim frm As Form
  Set frm = New Form2
End Sub

Expert Comment

ID: 8172311
you ask the same question twice :(
Look at the other place you asked this question

Accepted Solution

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
      'exit loop
      Exit For
   End If
If Not bFounded Then
   'form is not loaded, thus add it to forms collection
   Set frmX = Forms.Add(strName)
   'now you can show it
End If

Author Comment

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

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