T
TRO
Here is a query that I am having trouble with. The query selects the correct
data, but what I need is to only show the ZIP that matches in the second
table.
For example, if the [mh zip] is the field that matches in the [dealer sales
zips] table, then it should show in a field called [ZIP], but if it is the
[O1 ZIP] that matches, then it should show in the [ZIP] field.
SELECT [Vehicle Registrations].[Activity Date], [Vehicle
Registrations].[Transaction ID], [Vehicle Registrations].VIN, [Vehicle
Registrations].MMID, [Vehicle Registrations].[O1 ZIP], [Vehicle
Registrations].[O2 ZIP], [Vehicle Registrations].[MH ZIP], [Vehicle
Registrations].[R1 ZIP], [Vehicle Registrations].[R2 ZIP]
FROM [Vehicle Registrations]
WHERE ((([Vehicle Registrations].[O1 ZIP]) In (select zip from [dealer sales
zips] where [dealer license number] = forms![dealer report
selection]![dealer number] and [use] = true))) OR ((([Vehicle
Registrations].[O2 ZIP]) In (select zip from [dealer sales zips] where
[dealer license number] = forms![dealer report selection]![dealer number]
and [use] = true))) OR ((([Vehicle Registrations].[MH ZIP]) In (select zip
from [dealer sales zips] where [dealer license number] = forms![dealer
report selection]![dealer number] and [use] = true))) OR ((([Vehicle
Registrations].[R1 ZIP]) In (select zip from [dealer sales zips] where
[dealer license number] = forms![dealer report selection]![dealer number]
and [use] = true))) OR ((([Vehicle Registrations].[R2 ZIP]) In (select zip
from [dealer sales zips] where [dealer license number] = forms![dealer
report selection]![dealer number] and [use] = true)));
data, but what I need is to only show the ZIP that matches in the second
table.
For example, if the [mh zip] is the field that matches in the [dealer sales
zips] table, then it should show in a field called [ZIP], but if it is the
[O1 ZIP] that matches, then it should show in the [ZIP] field.
SELECT [Vehicle Registrations].[Activity Date], [Vehicle
Registrations].[Transaction ID], [Vehicle Registrations].VIN, [Vehicle
Registrations].MMID, [Vehicle Registrations].[O1 ZIP], [Vehicle
Registrations].[O2 ZIP], [Vehicle Registrations].[MH ZIP], [Vehicle
Registrations].[R1 ZIP], [Vehicle Registrations].[R2 ZIP]
FROM [Vehicle Registrations]
WHERE ((([Vehicle Registrations].[O1 ZIP]) In (select zip from [dealer sales
zips] where [dealer license number] = forms![dealer report
selection]![dealer number] and [use] = true))) OR ((([Vehicle
Registrations].[O2 ZIP]) In (select zip from [dealer sales zips] where
[dealer license number] = forms![dealer report selection]![dealer number]
and [use] = true))) OR ((([Vehicle Registrations].[MH ZIP]) In (select zip
from [dealer sales zips] where [dealer license number] = forms![dealer
report selection]![dealer number] and [use] = true))) OR ((([Vehicle
Registrations].[R1 ZIP]) In (select zip from [dealer sales zips] where
[dealer license number] = forms![dealer report selection]![dealer number]
and [use] = true))) OR ((([Vehicle Registrations].[R2 ZIP]) In (select zip
from [dealer sales zips] where [dealer license number] = forms![dealer
report selection]![dealer number] and [use] = true)));