I would like to be able to call a form and change it settings using a variable, something like
MyVar = "Form1"
MyVar.visible = true
This obviously doesn't work in this way. What can i do to accomplish this.
Printable View
I would like to be able to call a form and change it settings using a variable, something like
MyVar = "Form1"
MyVar.visible = true
This obviously doesn't work in this way. What can i do to accomplish this.
You can do this using a form object
dim objForm as Form
set objForm = Form1
objForm.Visible = false
Tom Cannaerts
[email protected]
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to produce bigger and better idiots. So far, the universe is winning -- Rich Cook
This doesn't do the trick yet.
Your code:
dim objForm as Form
set objForm = Form1
objForm.Visible = false
Here Form1 isn't variable. What I want to do is to call the form with a variable name.
nm = "Form1"
set ObjForm = nm
ObjForm.Visible = true
When I declare dim nm as Form
then it doesn't work. So what I need is some declations of a variable to be able to point to a form.
Dim x as Form, strName as string
strName = Text1.Text
set x = Forms.Add(strName)
x.Show
Iouri Boutchkine
[email protected]
Thanx, but does this also work for a form which was created during design-time?
The Iouri solution requires that the form exists (means: it has been created in design time).
Special thanks to Lothar "the Great" Haensler, Tom Archer, Chris Eastwood, TCartwright, Bruno Paris, Dr_Micahel
and all the other wonderful people who made and make Codeguru a great place.
Come back soon, you Gurus.
The Rater
Don't blame the ignorant for not knowing
Thanx, works perfectly
We don't...
Tom Cannaerts
[email protected]
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to produce bigger and better idiots. So far, the universe is winning -- Rich Cook
I never do. Have a nice day.
Special thanks to Lothar "the Great" Haensler, Tom Archer, Chris Eastwood, TCartwright, Bruno Paris, Dr_Micahel
and all the other wonderful people who made and make Codeguru a great place.
Come back soon, you Gurus.
The Rater
I've encountered another problem when using your suggestion. When i open de Form this way in runtime, it opens perfectly. But when calling a procedure in this form from another form or module a new window opens, which obviously isn't meant to.
My code looks like this
Sub Form1_Load()
Call OpenForms
Call EditText()
End Sub
Sub EditText()
Formauto1.Text1.Text = "SomeText"
End Sub
Sub OpenForms()
Dim x as Form, strName as string
strName = "Formauto1"
set x = Forms.Add(strName)
x.Show
End Sub
The form FormAuto opens correctly in the procedure OpenForms(). However it opens again when calling procedure EditText().
Any suggestions.