Question : Base Subform on Combo ID

Hey,

I have a combo box based on a table. It has two columns; The key which is hidden and the name of a location. On the form there is a subform which has a number of fields for equipment. This is based on another table. However, the tables are linked via a relationship. What I would like is when I select a locaton from the combo it changes the fields in the subform to match the location. Im not sure how to embed the query in my subform or how to take the ID from the drop down and embed it in some sort of global variable??
I have managed to get the ID into a global variable when the combo is selected. Can anyone tell me how I would put this in a query? Or anoher way in which to do this??

Thanks

Answer : Base Subform on Combo ID

Don't know if it would help but you can change the recordsource of the subform and also, if there is an (hidden) ID field in the subform, set the default value to the ID selected from the combo box, so that users can enter new records in the subform if required.

So for the afterupdate of the combo

Sub combo_Afterupdate()
Me.SubformControl.Form.RecordSource="SELECT whatever FROM yourtable WHERE ID=" & Me.cboCombo
Me.SubformControl.Form.IDFieldOnSubform.DefaultValue= Me.cboCombo
End Sub
Random Solutions  
 
programming4us programming4us