question on combo box

  • Thread starter Thread starter mike
  • Start date Start date
M

mike

Hi all,

I have a main form and have a subform within it. I have a
combo box in the subform. I'm trying to program the combo
box to read the value of a text box that is located in the
main form. Is it possible for the combo box to read a
value of a text box in the main form.

Secondly, how do you disable the combo box from editing?

Thanks for the help...

mike
 
Sure it is. You can do various techniques to have the
value in the combo box key to a value in the text box.
You could set the combo box and the sub form as variable
on the main form using the With Events. Then, using the
afterupdate procedure on the text box, have the value
updated in the combo box. Make sure you are sending the
value that will match the bound column of the combo box.
You can also you me.subformname.form.controlname =
me.textboxname in the afterupdate procedure for the text
box on the main form.

ds
 
The problem is you can't get the combo box to dynamically
display different data after the form is loaded which is
what you need if you want it linked to a field on a
different form so you will need some event like a button
or perhaps focus event that will refresh the compbo box's
control Source.

First you need your combo box to have a Control Source of:
=[Forms]![ParentFormName]![TestBoxName]

On the main form some trigger like a button will have
code:
Me.SubFormname.Form.Controls.Item("ComboBoxName").Requery

This will refresh the combo box. As to your second
question about preventing editing,you can set the Limit to
List to Yes which will do basically the same thing.

-Cameron Sutherland
 
WRONG!!!!! What are you talking about??? Please don't
assist with completely wrong answers. Changing the value
of a combo box "dynamically" (ie-while the form is
running) is done through a little thing called ... CODE!!!

You dont need a button, just use the events of the
control. VBA is EVENT driven, and the procedures and
events of each control allows you to change nearly
anything dynamically.



-----Original Message-----
The problem is you can't get the combo box to dynamically
display different data after the form is loaded which is
what you need if you want it linked to a field on a
different form so you will need some event like a button
or perhaps focus event that will refresh the compbo box's
control Source.

First you need your combo box to have a Control Source of:
=[Forms]![ParentFormName]![TestBoxName]

On the main form some trigger like a button will have
code:
Me.SubFormname.Form.Controls.Item("ComboBoxName").Requery

This will refresh the combo box. As to your second
question about preventing editing,you can set the Limit to
List to Yes which will do basically the same thing.

-Cameron Sutherland
-----Original Message-----
Hi all,

I have a main form and have a subform within it. I have a
combo box in the subform. I'm trying to program the combo
box to read the value of a text box that is located in the
main form. Is it possible for the combo box to read a
value of a text box in the main form.

Secondly, how do you disable the combo box from editing?

Thanks for the help...

mike
.
.
 
Back
Top