Stapes said:
Hi Again
Sorry - I haven't explained myself very well. The user might not know
who is the owner of a boat without looking. The idea is that he can
select the boat name from the top of the main form, and his chosen
boat appears in the subform with the correct customer details in the
main form. The customer details in the main form are coming out OK,
but the subform and the combo box keep reverting back to the first
boat for the customer. Unfortunately, the boat name field is NOT in
both tables, so I cannot link it using MasterLink and ChildLink.
Stapes
So your basic requirement is that you want to navigate to a certain parent
record based on filter criteria applied to data in the subform correct? In
other words you want to enter a boat name and have the parent form filtered
to the customer that owns that boat and also have the subform filtered to
that specific boat.
To do that you need to either base you main form on a query that includes
both the Customers table and the Boats table so you can filter on the fields
in the Boats table or else you need to use an In() clause for your filter.
The former might affect the editability of your main form or cause multiple
records to appear per customer so I don't think you would like that
approach.
In the AfterUpdate event of the ComboBox where you select a boat name you
have code...
Me.Filter = "[CustomerNumber] In(SELECT CustomerNUmber FROM Boats WHERE
BoatName = '" & Me!ComboBoxName & "'"
Me.FilterOn = True
That should filter the main form so that it shows the correct Customer.
Then if you set the MasterLnk and ChildLink properties to both the customer
number and the boat name the subform should display that particular boat.
ChildLink properties are required to be based on field names in the
subform's RecordSource, but there is no such requirement for MasterLink
properties. The MasterLink property can just refer to the name of the
ComboBox where you select a boat name. You do not need a boat name field in
the main form. You might get fooled here because the builder form for
entering those properties will only allow field names to be entered. Just
don't use that and type the properties directly into the property boxes.