How can I reference a control using a string that contains the control's name?

B

Brad Marshall

I want to set a value in a text box control on a form in VB code. I have a
string that contains the control name. This works:

Me.("ControlName") = "Control Value String"

Great! But now I want to reference a control on another open form. This
doesn't work:

Form_Other.("ControlName") = "Control Value String"

How can I establish a reference to a control on another open form whan I
have a string that contains the name of the control?

Thanks. Brad Marshall
 
S

Sandra Daigle

Try this:

Forms!Form_Other("ControlName")

or

Forms!Form_Other.controls("ControlName")
 
B

Brad Marshall

Oh, the sweet feeling of success. This works:
Forms!Form_Other("ControlName")

Thanks Sandra,

Brad

Sandra Daigle said:
Try this:

Forms!Form_Other("ControlName")

or

Forms!Form_Other.controls("ControlName")

--
Sandra Daigle
[Microsoft Access MVP]
For the benefit of others please post all replies to this newsgroup.

Brad said:
I want to set a value in a text box control on a form in VB code. I have
a string that contains the control name. This works:

Me.("ControlName") = "Control Value String"

Great! But now I want to reference a control on another open form. This
doesn't work:

Form_Other.("ControlName") = "Control Value String"

How can I establish a reference to a control on another open form whan I
have a string that contains the name of the control?

Thanks. Brad Marshall
 

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