Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Form reference using a variable

Status
Not open for further replies.

jtseltmann

Programmer
Jan 15, 2002
149
US
Trying to use a string variable to create a form name reference and i just can't get it to work. Found some help here on the boards and tried this but I generate an error. The error is "...can't find the form 'MasterdataSplitInd' referred to in a macro or expression or visual basic code."

Using access 2000

Inside a function:
Code:
Dim thisform as Form
Dim thisstring as string

'set the form name
thistring = "MasterdataSplitInd"
Set thisform = Forms(thisstring)
 
Is MasterdataSplitInd an open mainform when the code is running ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
PHV,
Let me correct that. The form is open. It is a sub form on my MainMenu. I use a tab control and the 'MasterdataSplitInd' is a sub form on one of the tabs. Does this help clear it up a bit?
Thanks.
 
You may try something like this:
Set thisform = Forms("MainMenu").Controls(thisstring).Form

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
PHV,
NG on that one...it then thinks the 'MasterdataSplitInd' is a control on the Main Menu.
 
Thanks PHV and Eupher for your help. I was able to get this working with a little help from all!

j.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top