Rik_StHelens
Registered User.
- Local time
- Today, 21:03
- Joined
- Sep 15, 2009
- Messages
- 164
I have a query which pulls the dates of all jobs performed on a customers vehicles.
Currently we create a summary report in excel which shows in which of the last 12 months their vehicles were inspected, which takes a long time.
Currently my query will look at the inspection date month, and put checked under the corresponding month in the results. I would like it to look like this
Eg:
Reg Jan Feb Mar Apr May Jun etc
AB1 Checked Checked Checked Checked
AB2 Checked Checked Checked
AB3 Checked Checked Checked
But at present it looks like this:
Reg Jan Feb Mar Apr May Jun etc
AB1 Checked
AB1 Checked
AB1 Checked
AB1 Checked
AB2 Checked
AB2 Checked
AB2 Checked
Now i know that it is doing it like this because it creates a new line every time it finds a new instance of that Reg being checked in the table.
how would i recreate the desired format as shown in my first example?
here is my current sql:
SELECT tblVehicle.Customer, tblVehicle.FleetName, tblVehicle.RegistrationNumber, IIf(Month([InspectionDate])="1","Checked","") AS Jan, IIf(Month([InspectionDate])="2","Checked","") AS Feb, IIf(Month([InspectionDate])="3","Checked","") AS Mar, IIf(Month([InspectionDate])="4","Checked","") AS Apr, IIf(Month([InspectionDate])="5","Checked","") AS May, IIf(Month([InspectionDate])="6","Checked","") AS Jun, IIf(Month([InspectionDate])="7","Checked","") AS Jul, IIf(Month([InspectionDate])="8","Checked","") AS Aug, IIf(Month([InspectionDate])="9","Checked","") AS Sep, IIf(Month([InspectionDate])="10","Checked","") AS Oct, IIf(Month([InspectionDate])="11","Checked","") AS Nov, IIf(Month([InspectionDate])="12","Checked","") AS [Dec]
FROM tblVehicle LEFT JOIN tblInspection ON tblVehicle.RegistrationNumber = tblInspection.Registration
WHERE (((tblVehicle.Customer) Like "*" & [Customer Name] & "*") AND ((tblInspection.InspectionDate)>Date()-365));
Thanks for your help

Currently we create a summary report in excel which shows in which of the last 12 months their vehicles were inspected, which takes a long time.
Currently my query will look at the inspection date month, and put checked under the corresponding month in the results. I would like it to look like this
Eg:
Reg Jan Feb Mar Apr May Jun etc
AB1 Checked Checked Checked Checked
AB2 Checked Checked Checked
AB3 Checked Checked Checked
But at present it looks like this:
Reg Jan Feb Mar Apr May Jun etc
AB1 Checked
AB1 Checked
AB1 Checked
AB1 Checked
AB2 Checked
AB2 Checked
AB2 Checked
Now i know that it is doing it like this because it creates a new line every time it finds a new instance of that Reg being checked in the table.
how would i recreate the desired format as shown in my first example?
here is my current sql:
SELECT tblVehicle.Customer, tblVehicle.FleetName, tblVehicle.RegistrationNumber, IIf(Month([InspectionDate])="1","Checked","") AS Jan, IIf(Month([InspectionDate])="2","Checked","") AS Feb, IIf(Month([InspectionDate])="3","Checked","") AS Mar, IIf(Month([InspectionDate])="4","Checked","") AS Apr, IIf(Month([InspectionDate])="5","Checked","") AS May, IIf(Month([InspectionDate])="6","Checked","") AS Jun, IIf(Month([InspectionDate])="7","Checked","") AS Jul, IIf(Month([InspectionDate])="8","Checked","") AS Aug, IIf(Month([InspectionDate])="9","Checked","") AS Sep, IIf(Month([InspectionDate])="10","Checked","") AS Oct, IIf(Month([InspectionDate])="11","Checked","") AS Nov, IIf(Month([InspectionDate])="12","Checked","") AS [Dec]
FROM tblVehicle LEFT JOIN tblInspection ON tblVehicle.RegistrationNumber = tblInspection.Registration
WHERE (((tblVehicle.Customer) Like "*" & [Customer Name] & "*") AND ((tblInspection.InspectionDate)>Date()-365));
Thanks for your help