Discussion Locked

Dynamic Combo Boxes in MS Access97

0 helpful
7 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

I have a dynamic combo box in a subform that displays different values depending on the value of a field in the main form. So if the main forms cboProductLine field says we are working on "Baseball" then the combo box on the subform gives choices like Gloves, Bats, or Rosin; if it says "Golf" then the choices on the subform combobox are Golf Bag, Putter, or Driver. My combo box Recordsource is a query that puts the current value of the main form's cboProductLine control.

My problem is making sure the subform combobox is requeryed to get the right value under all circumstances. It works well when clicking through existing records but usually fails when a new main record is added and assigned a ProductLine. I have tried tying a Requery to the form and subform Current and the ProductLine_Change events, but get inconsisent results. (Also, Requery is not supported when a Filter is used.)

Is there a rule regarding what events to use to ensure that a dynamic combo box in a subformis updated and shows the appropriate options?

7 replies

by donq

Base your Combo box on a query that lists the main form's (filter) field as a "Criteria:" entry to insure you always display current "FILTERED" recordsets base on the user selection.

by ashilep

The fact that you can not execute a filter on a main form that has a Requery method is a prolem, but not my main one. I am more concerned tha--leaving aside filtering--under some combinations of actions the combo box in the subform does NOT show the correct set of choices. I hope there is some event or events that I can have fire off a Requery of the combo box, and always be assure that the correct combobox options will appear.

by meares

I built the same type of form using a combo box in the subform to pull in a list. Found that while on the main form (maybe where they select the next record) that you can do the following statements added to the field that they select "baseball" "Golf" etc...

Me.subFormName.Form.Refresh
Me![subFormName].Form![Combo38] = ""

Last line will take the current data out of the combo box so that it start with a null and not the last value from before.

good luck.... hope i explained this well.

by meares

I built the same type of form using a combo box in the subform to pull in a list. Found that while on the main form (maybe where they select the next record) that you can do the following statements added to the field that they select "baseball" "Golf" etc...

Me.subFormName.Form.Refresh
Me![subFormName].Form![Combo38] = ""

Last line will take the current data out of the combo box so that it start with a null and not the last value from before.

good luck.... hope i explained this well.

This discussion is closed to new replies.