Listbox row source in a subform

  • Thread starter Thread starter Robin
  • Start date Start date
R

Robin

Hi

I have a subform with linked fields to the main form, such that the subform
correctly displays only those records related to the main form record
(contact and meeting notes relating to the person on the main form).

I want to put a List Box on the subform that will populate with these same
related records, but I'm not sure how to set the row source to display only
the related records - if I use the table used by the subform I get all
records - not just the related ones.

Is there a way to do this?

Regards

Robin
 
Robin said:
I have a subform with linked fields to the main form, such that the subform
correctly displays only those records related to the main form record
(contact and meeting notes relating to the person on the main form).

I want to put a List Box on the subform that will populate with these same
related records, but I'm not sure how to set the row source to display only
the related records - if I use the table used by the subform I get all
records - not just the related ones.


Set the list box's RowSource to a query that uses the
linking field(s?) as criteria.

For example, if the subform control's LinkMaster property is
txtID, then set the criteria of the query's field
identified in the LinkChild property to:
Forms!mainformname.txtID
 
Marshall Barton said:
Set the list box's RowSource to a query that uses the
linking field(s?) as criteria.

For example, if the subform control's LinkMaster property is
txtID, then set the criteria of the query's field
identified in the LinkChild property to:
Forms!mainformname.txtID

Thank you Marshall. I didn't realise I could reference form controls in a
query.

I had to use the main form on current event to requery the list box,
otherwise the list box content stayed in it's initial state, but having done
so this works perfectly.

Many thanks.

Robin
 
Back
Top