sub form

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

I have a main form containing a combo box. Based on the combo box value, a
sub form displays data. Everything is fine when I open the form or change
records. If I change the value of my combo box, I need the sub form to
display the information based on the new value of the combo box. How do I do
this? I know it would be after update but what would the code be? Do I
reference the whole sub form as a requery or just one of the boxes? I need
the whole sub form to display the new data.

Thanks,
 
Assuming the value in the combo matches a field within the subform
recordsource, you could just set the Link Master/Child property for the
subform. The Master would be the name of your combo and the Child would be
the name of the field within the subform recordsource.

If the above is not an option, you need to programmatically set the
recordsource for the subform from the AfterUpdate event for the combobox,
i.e.,

Me.SomeSubForm.Form.RecordSource = "SELECT * FROM SomeTable WHERE SomeField
= '" & Me.SomeCombobox & "'"

When you assign a new recordsource, the requery is automatic.
 
Karen,
On AfterUpdate of the combo...
YourSubformName.Requery
should do it.
hth
Al Camp
 
Back
Top