Filtering Subforms according to main form

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

Guest

Hi all,

I'm only a beginner with Access and I have stumbled. I have created a main
form for all of our customers and then a subform for all of their cars. The
main form's key is the customer name and the subform's key is the rego, but
the customer's name is also listed in the car details in order to link the
two together. I have a one to many relationship for the name of the
customers. I have used the wizard to create the main form with the subform
but when I go into the customer form and click on the cars button, it doesn't
list any cars - filter is on. If I take the filter off, it lists all of the
cars in the database. How do I get it so that only the cars with the same
customer name as the main form is listed?

Thanks

Lehcara
 
If the cars form is a subform on the main form, you do not need to
have a button to see the cars for that customer.

Go to the properties of the subform and go to the Data tab. If you
double click on the parent child relationship line it should bring up
a wizard to ask what parts are related. Once you set that up, you
shouldn't have to do any filtering or anything like that, it should be
automatic.

Ron
 
Hi all,

I'm only a beginner with Access and I have stumbled. I have created a main
form for all of our customers and then a subform for all of their cars. The
main form's key is the customer name and the subform's key is the rego, but
the customer's name is also listed in the car details in order to link the
two together. I have a one to many relationship for the name of the
customers. I have used the wizard to create the main form with the subform
but when I go into the customer form and click on the cars button, it doesn't
list any cars - filter is on. If I take the filter off, it lists all of the
cars in the database. How do I get it so that only the cars with the same
customer name as the main form is listed?

DON'T use customer names as links. They are not unique! I know three
men named Fred Brown; can you assume that you will never have two
different customers who happen to have the same name? I wouldn't count
on it - and I *certainly* wouldn't base the integrity of may database
on it!

Instead, you should have a unique CustomerID; and Autonumber is one
easy way.

Your Subform should have this CustomerID as the Master Link Field, and
the linked CustomerID field in the Cars table as a child link field.
No code and no special query are needed - the subform takes care of
the linkage for you.

John W. Vinson [MVP]
 
Back
Top