using variable in qualified form name

L

lynn

Hi,
Is it possible to do something like this:

dim sformName as string
sFormname = "OtherForm"

And then refer the form control

forms!OtherForm.txtBox1

as

forms!sFormName!txtBox1

If so what is the correct syntax?

Thanks
 
T

tina

you can't use a string variable; use a form variable, as

Dim fWhatever As Form
fWhatever = Forms!FormName

fWhatever.txtBox1

the system will recognize variable fWhatever as the
specific form object you assign to it.

hth
 
J

John Henriksen

Hi Lynn !

You are allmost there but try this

Dim sformName as string ' thats okay
sformName = "Otherform" ' okay

now

Forms(sformName)!txtbox1.text = "something"

hope you can use it

John
 
M

Marshall Barton

lynn said:
Is it possible to do something like this:

dim sformName as string
sFormname = "OtherForm"

And then refer the form control

forms!OtherForm.txtBox1

as

forms!sFormName!txtBox1

If so what is the correct syntax?

Use this syntax:

Forms(sFormname)!txtBox1
 
M

Marshall Barton

Hey John, your VB is showing ;-)
In Access VBA drop the Text property and use Value instead.
It's the default property so you don't have to specify it if
you don't want to. (Note: the Text property is only useful
while the control is being edited)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top