Click to See Complete Forum and Search --> : Sub Forms in Access


Andrew_Fryer
October 16th, 2001, 07:47 AM
Hello, I have a problem with Access that I hope someone can help with.

I have a main form entitled "Main", which contains a sub form entitled "DataSheet", this is a datasheet representation of a table in the database. Within the main form, there is a combo box and when the user selects an item from here I need to update the sub form so that it queries the data on this value. Is there any easy way to do it?

Thanks

Andrew

TB_Guy_2000
October 16th, 2001, 12:08 PM
This can be done and is very common. It does involve a bit of vb code to make it work.

Subform: The recordset used must reference the combobox of the main form (datasheet field = forms!main.combo1).

Main form: The combo box "should" have a default value for the sub form to work off of, but not required. In the click event of the combo box, requery the subform (that's the vb code portion).

Hope this helps.

TB_Guy_2000

Andrew_Fryer
October 16th, 2001, 02:26 PM
Hello,

Thanks very much for your help - I actually found a different way to do it, but similar to yours.

In the event ComboBox_AfterUpdate I call a function within the subform which passes a parameter containing the data item I wish to filter on. As, in my main form I need to add and delete items this method can be done using several functions.

Thanks for your help though, thought I would post a different solution incase anyone was interested!

Andrew