Change name property of control dynamically

  • Thread starter Thread starter J. Shrimp, Jr.
  • Start date Start date
J

J. Shrimp, Jr.

Have a sub datasheet that has seven controls.
Six are constant but one control is based on
what is selected in the combo box on the main form.
Can change what the source for the seventh control
is by me.subform!form.txt1 = me.cmbbox1.
However the NAME of the control - "txt1" is
still txt1.
Is there any way to dynamically change the
control name property also?
Get an error saying "Object required"
for the line:
Me.SubAll.Form.txt1.ControlSource.Name = "Payables"
 
You can only change the Name property of a control if the form is open in
design view.

You can change the ControlSource of the control any time, assuming that (as
in your example) the control does not have the same name as one of your
fields.
 
Just set the ControlSource property:
Me.SubAll.Form.txt1.ControlSource= "Payables"
Leave out the .Name.
 
Back
Top