Solved

Load form with the use of variables

Posted on 2002-05-23
5
142 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
  • 2
  • 2
5 Comments
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
Comment Utility
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
Comment Utility
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 142

Expert Comment

by:Guy Hengel [angelIII / a3]
Comment Utility
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
Comment Utility
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
Comment Utility
Thanks TimCottee for the answer. It wroked just great. Thanx a lot for the advice.

Take Care.

Joyriderank.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…

771 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now