Hello all,
I have a table of vehicle information I have been trying to query all morning.
Currently my query looks like this
Code:
SELECT Vehicles.EmpID, Vehicles.Make, Vehicles.Model, Vehicles.Color, Vehicles.LicNum, Vehicles.LicStFROM Vehicles
WHERE
(((Vehicles.Make) Like "*" & [Forms]![Vehicle Search]![txtMake] & "*") AND
((Vehicles.Model) Like "*" & [Forms]![Vehicle Search]![txtModel] & "*") AND
((Vehicles.Color) Like "*" & [Forms]![Vehicle Search]![txtColor] & "*") AND
((Vehicles.LicNum) Like "*" & [Forms]![Vehicle Search]![txtLicNum] & "*") AND
((Vehicles.LicSt) Like "*" & [Forms]![Vehicle Search]![txtLicState] & "*"))
ORDER BY Vehicles.EmployeeID;
And my table is laid out like this
VehID |
EmpID |
Make |
Model |
Color |
LicNum |
LicSt |
1 |
5 |
Ford |
Ranger |
White |
12345 |
MS |
2 |
4 |
Honda |
Accord |
White |
|
|
My issue is that if I search for white I only see record 1 and if I search for Honda no records appear at all.
I have also tried the following, but that ends up showing all records.
Code:
FROM Vehicles
WHERE
(((Vehicles.Make) Like "*" & [Forms]![Vehicle Search]![txtMake] & "*") AND
((Vehicles.Model) Like "*" & [Forms]![Vehicle Search]![txtModel] & "*") AND
((Vehicles.Color) Like "*" & [Forms]![Vehicle Search]![txtColor] & "*") AND
((Vehicles.LicNum) Like "*" & [Forms]![Vehicle Search]![txtLicNum] & "*") AND
((Vehicles.LicSt) Like "*" & [Forms]![Vehicle Search]![txtLicState] & "*"))
OR
(((Vehicles.Make) Is Null) AND
((Vehicles.Model) Is Null) AND
((Vehicles.Color) Is Null) AND
((Vehicles.LicNum) Is Null) AND
((Vehicles.LicSt) Is Null))
ORDER BY Vehicles.EmployeeID;
[/CODE]
Is there something i am overlooking or missing?