Populate Variable Text Box

  • Thread starter Thread starter Jason Gyetko
  • Start date Start date
J

Jason Gyetko

I need to populate a text box of a variable form and variable field. I have
the following bit of code which I thought would work, but 'myform' is being
recognized as a string instead of a form or textbox. How can I build the
path to a form and textbox.value so I can set it accordingly? Any
suggestions would be greatly appreciated. Thanks.

Public Sub PopulateTextBox(FormName, FormFieldName)
Dim myform
myform = "Forms!" & FormName & "!" & FormFieldName
myform = "Display in Text Box"
End Sub

If I just use this hardcoded line, it works fine:

Forms!anyform!anytextbox.Value = "Display in Text Box"
 
Jason Gyetko said:
I need to populate a text box of a variable form and variable field.
I have the following bit of code which I thought would work, but
'myform' is being recognized as a string instead of a form or
textbox. How can I build the path to a form and textbox.value so I
can set it accordingly? Any suggestions would be greatly
appreciated. Thanks.

Public Sub PopulateTextBox(FormName, FormFieldName)
Dim myform
myform = "Forms!" & FormName & "!" & FormFieldName
myform = "Display in Text Box"
End Sub

If I just use this hardcoded line, it works fine:

Forms!anyform!anytextbox.Value = "Display in Text Box"

Use

Forms(FormName).Controls(FormFieldName) = "Display in Text Box"

You don't need to specify ".Value", though you may if you prefer.
 
Back
Top