Change name property of control dynamically

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"
 
A

Allen Browne

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.
 
M

MacDermott

Just set the ControlSource property:
Me.SubAll.Form.txt1.ControlSource= "Payables"
Leave out the .Name.
 

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