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

  • Thread starter Thread starter Brad Marshall
  • Start date Start date
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
 
Try this:

Forms!Form_Other("ControlName")

or

Forms!Form_Other.controls("ControlName")
 
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
 
Back
Top