ShabanaHafiz
Programmer
I am using Microsoft Access 2003.
I created two tables to enter details of Vehicle Running and Maintenance; LogBook and VehicleMaint.
LogBook table records Vehicle Running Details:
OfficeID
VehicleID
SerialNumber
DateOfTravel
KMBeforeTravel
KMAfterTravel
VehicleMaint table records Fuel, Maintenance and Repair Cost.
VehicleID
InvoiceNumber
InvoiceDate
FuelCost
RepairCost
I need to create a query to use as report’s Record Source. In the report, I need to show total running per vehicle and cost. I need to show the following fields:
OfficeID
VehicleID
KMTraveled: [KMAfterTravel – KMBeforeTravel]
TotalCost: [FuelCost] + [RepairCost]
In the Design View of the query, I selected OfficeID, VehicleID, KMTraveled:[KMAfterTravel] – [KMBeforeTravel] and TotalCost: [FuelCost] + [RepairCost] in the field line. Then I clicked Totals button, and selected Group By, Group By, Sum, Sum for the four fields respectively.
I did not get the sum amount accurate. The joining operation is inserting total cost for each vehicle running entry. For example, if there is one invoice entered for Vehicle VH1 with total cost 50, in the query I am getting:
OfficeID VehicleID KMTraveled TotalCost
HO VH1 100 50
HO VH1 200 50
HO VH1 300 50
And after applying group by clause, I am getting:
HO VH1 600 150
I need the following result:
HO VH1 600 50
There can be more than one invoices entered for a vehicle. For example, vehicle VH2 has three invoices entered with total cost 20, 1000 and 200. In that case, for each logbook entry, I am getting:
HO VH2 25 20
HO VH2 25 1000
HO VH2 25 200
HO VH2 475 20
HO VH2 475 1000
HO VH2 475 200
On applying Group By, I am getting:
HO VH2 1500 2440
I need the following result:
HO VH2 500 1220
I created two tables to enter details of Vehicle Running and Maintenance; LogBook and VehicleMaint.
LogBook table records Vehicle Running Details:
OfficeID
VehicleID
SerialNumber
DateOfTravel
KMBeforeTravel
KMAfterTravel
VehicleMaint table records Fuel, Maintenance and Repair Cost.
VehicleID
InvoiceNumber
InvoiceDate
FuelCost
RepairCost
I need to create a query to use as report’s Record Source. In the report, I need to show total running per vehicle and cost. I need to show the following fields:
OfficeID
VehicleID
KMTraveled: [KMAfterTravel – KMBeforeTravel]
TotalCost: [FuelCost] + [RepairCost]
In the Design View of the query, I selected OfficeID, VehicleID, KMTraveled:[KMAfterTravel] – [KMBeforeTravel] and TotalCost: [FuelCost] + [RepairCost] in the field line. Then I clicked Totals button, and selected Group By, Group By, Sum, Sum for the four fields respectively.
I did not get the sum amount accurate. The joining operation is inserting total cost for each vehicle running entry. For example, if there is one invoice entered for Vehicle VH1 with total cost 50, in the query I am getting:
OfficeID VehicleID KMTraveled TotalCost
HO VH1 100 50
HO VH1 200 50
HO VH1 300 50
And after applying group by clause, I am getting:
HO VH1 600 150
I need the following result:
HO VH1 600 50
There can be more than one invoices entered for a vehicle. For example, vehicle VH2 has three invoices entered with total cost 20, 1000 and 200. In that case, for each logbook entry, I am getting:
HO VH2 25 20
HO VH2 25 1000
HO VH2 25 200
HO VH2 475 20
HO VH2 475 1000
HO VH2 475 200
On applying Group By, I am getting:
HO VH2 1500 2440
I need the following result:
HO VH2 500 1220