Solved

Load form with the use of variables

Posted on 2002-05-23
5
147 Views
Last Modified: 2010-05-02
Hi Experts,

I am facing a problem in loading forms in VB, by calling the form name through a variable. Like :

dim ank as string
ank = "frmMain"
Load ank

the above code is giving me problems and I am unable to figure out a way to get past this problem. I think that the solution would be easy for you experts with years experience but silly me could not get through this small problem. I would really appreciate all the help I can get with this problem of mine.

Chalo that will be all for now. TAKE CARE you guys and gals.

Thanks in advance. :):):)

Joyriderank.
0
Comment
Question by:joyriderank
[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
  • 2
  • 2
5 Comments
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 7029260
unfortunately, even we with years of experience don't have anything except workarounds for this problem. Unless the form is not loaded, you can't get it's object reference and check it's name, and thus you can't load one (as the load function requests an object).
CHeers
0
 
LVL 43

Accepted Solution

by:
TimCottee earned 50 total points
ID: 7029277
angelIII you can use this of course:

Dim frmToLoad As Form
dim ank as string
ank = "frmMain"
Set frmToLoad = Forms.Add (Ank)

which does work. Of course if the string contains a form that is not present in the project then an error will occur but this can be trapped and handled in the usual way.
0
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 7029279
sorry, you are right... but this is new in VB6, I start to loose my vb-knowledge, doing too much stuff in db :(
CHeers
0
 
LVL 1

Author Comment

by:joyriderank
ID: 7030045
Thanks for your help with the problem guys. I will check out your suggestion TimCottee and get back to you if I face any problems.

Chalo that will be all for now. TAKE CARE guys. :):):)

Joyriderank.
0
 
LVL 1

Author Comment

by:joyriderank
ID: 7036422
Thanks TimCottee for the answer. It wroked just great. Thanx a lot for the advice.

Take Care.

Joyriderank.
0

Featured Post

Industry Leaders: 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

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

687 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