Query a table using a field

  • Thread starter Thread starter jørgensen
  • Start date Start date
J

jørgensen

I have the following problem:

Lets say I have a table (tbl_cars):

name: brand: version:
Car1 BMW 320
Car2 BMW 320
Car3 BMW 323
Car4 BMW 325
Car5 VW Golf
Car6 VW Golf
Car7 VW Golf
Car9 VW Passat

and a table (tbl_carsinuse):
use: brand: version:
InUse1 VW Golf
InUse2 BMW _________


Now I have selected the BMW from a drop down list generated from
table(tbl_carsinuse).

When I press on the dropdown list in the table (tbl_carsinuse) to obtain the
underlined "version", I want a list including: 320,323,325. I DONT want the
Golf or Passat. I use the query:

SELECT tF.version
FROM tbl_cars tF, tbl_carsinuse tK
WHERE tF.brand = tK.brand


My problem is, that the versions for the VW also is included. How do I add
the specific cell reference in the query?

Martin Jørgensen, Denmark
 
If your brand is selected in cbBrand and version is to be displayed in
cbVersion, put the following in the AfterUpdate event of the cbBradn:

Me.cbVersion.RowSource = "SELECT DISTINCT Version FROM tbl_cars WHERE
Brand = '" & Me.cbBrand & "'"

Or, you can simply put a static statement in the RowSource property of
cbVersion, if your Versions don't change much:

SELECT DISTINCT Version FROM tbl_cars WHERE Brand = '" & Forms("MyForm")![Brand]

That should do it.
Pavel
 
Back
Top