recordset use for subforms

nishantd

Registered User.
Local time
Today, 16:07
Joined
Feb 20, 2004
Messages
33
Would it be possible to use a listbox within a subform that only populates itself with the data associated with that subform?

For instance, FormA has a listbox from which all rows are populated into this listbox. Also, FormB (subform within FormA) has a ListBox as well.

How can I populate the ListBox in FormB (subform within FormA), when a row in FormA's ListBox is seleced (these related tables)? Would I just need to create a query to do this or can I use the current record set of FormB to peform a requery on the ListBox?

Thank you,
Nishant
 
You don't need anything quite so complicated. Forms and subforms, when they are "connected", have a master link and child link field. The function of these fields (which you can see by clicking once on the subform object in design view) is to link the form to the subform. When the value that you choose in the master link field (on the main form) changes, the subform will move to corresponding records in the child link field.

Have the master link field be your listbox on the main form. Have your child link field be the listbox on your subform.
 
I do see that the forms are linked via the common identifier. However, when you say "have the master link field be your listbox", am I allowed to link the two listboxes just by putting their names in the respective master/child link fields? It seems I would need to bind the listboxes to some value in each of the respective forms. correct?

As I have things set up now, the listbox in the main form works as it is supposed to and pulls up appropriate information in the subform when a row is clicked (Thank you for that response in an earlier thread). However, if I add a listbox to the subform, I shouldn't be adding a row source because wouldn't that pull the same data as specified by that row source select statement, regardless of what row is clicked in the listbox of the main form?
Thank you,
Nishant

dcx693 said:
You don't need anything quite so complicated. Forms and subforms, when they are "connected", have a master link and child link field. The function of these fields (which you can see by clicking once on the subform object in design view) is to link the form to the subform. When the value that you choose in the master link field (on the main form) changes, the subform will move to corresponding records in the child link field.

Have the master link field be your listbox on the main form. Have your child link field be the listbox on your subform.
 
Last edited:
It seems I would need to bind the listboxes to some value in each of the respective forms. correct?
Both the form and subform need to be bound for the link to work. I'm not sure if the particular fields involved need to be bound, but I've only used them that way. So, when you select a record in the main form, only related records show up in the subform.
 
dcx693 said:
Both the form and subform need to be bound for the link to work. I'm not sure if the particular fields involved need to be bound, but I've only used them that way.

It may seem I need to bind the particular fields between the two listboxes.
My dilemma involves setting the source for the listbox in the subform. If I give a static source, such as a table ,then the listbox only displays that information regardless of which row is selected in the main form's listbox. The links between the main form and subform are working fine, but it's the actual source information within the subform's listbox. Is there a way to set the source for the listbox to use the subform's current recordset? This way, the listbox will display only the relevant data.

Thank you,
Nishant Desai
 

Users who are viewing this thread

Back
Top Bottom