using a variable for something

S

sturner333

I am using the following line to write to a text box on a different form that
is open:
Forms![sheet2]![HVD] = Me!Text14
I would like to make this line more generic and use a information from the
current form to substitute for part of the line:
Dim tempDiv As String
tempDiv = Me!division
Forms![sheet2]![tempDiv] = Me!Text14
Is there a way to do this or a different set of commands to write to the
object on a different form.
Thanks for the help.
 
A

Allen Browne

You can code like this:
Dim txt As Textbox
Set txt = Forms!Sheet2!tempDiv
txt = Me.Text15

If you need to pass the text boxes to another function to do the assignment,
it would be like this:

Function SetTheThing(txtSource As Textbox, txtTarget As Textbox)
txtTarget = txtSource
End Function
 
Top