I will do that this afternoon, after I get home from work. Yes, I also have another work computer at home (different job). The database that I'm working on is on their server, and I connect with their laptop. I will post the SQL code, and show some sample data.
I know there has to be a fix, because I can't be the only person that ever had to deal with this. I have a workaround right now (2 queries - one for trucks and one for drivers), but I really need for my user to be able to pull one report with this data.
[MENTION]
SELECT [tbl_Owner Operators].ID, tbl_terminals.Terminals, tbl_Regions.Regions, [tbl_Owner Operators].LastName, [tbl_Owner Operators].FirstName, [tbl_Owner Operators].DBA, [tbl_Owner Operators].Email, [tbl_Documentation Checklist].[Contractor Service Agreement], [tbl_Documentation Checklist].[Schedule A Form], [tbl_Documentation Checklist].[Contractor Insurance], [tbl_Documentation Checklist].[Escrow Deduction], [tbl_Documentation Checklist].[Escrow Transfer], [tbl_Documentation Checklist].[Lease Schedule and Signed Lease], [tbl_Documentation Checklist].[Employee Lease Agreement], [tbl_Documentation Checklist].[URS Application], [tbl_Documentation Checklist].[Employee Data Record], [tbl_Documentation Checklist].[Direct Deposit request], [tbl_Documentation Checklist].[W-9], [tbl_Documentation Checklist].[Federal ID Number], [tbl_Documentation Checklist].[Valid DL], [tbl_Documentation Checklist].CARBCompliance, [tbl_Documentation Checklist].Worksheet, [tbl_Documentation Checklist].[2290 Hwy Use Tax Form], [tbl_Documentation Checklist].[Tractor-Trailer Title], [tbl_Documentation Checklist].[Trailer Registration], [tbl_Documentation Checklist].[DOT Inspection], [tbl_Documentation Checklist].[WGT Slip], [tbl_Documentation Checklist].[Lien Holder Name], [tbl_Documentation Checklist].[Lien Holder Address], [tbl_Documentation Checklist].[Lien Holder City], [tbl_Documentation Checklist].[Lien Holder State], [tbl_Documentation Checklist].[Lien Holder Zip], [tbl_Documentation Checklist].[Title Work Required], [tbl_Documentation Checklist].[Plate Transfer], [tbl_Documentation Checklist].OpenorEnclosed, tbl_Trucks.TruckNo, tbl_Trucks.TractorPrice, tbl_Trucks.[Tractor Purchase Date], tbl_Trucks.TractorYear, tbl_Trucks.TractorMake, tbl_Trucks.TractorVIN, tbl_Trucks.TractorAxles, tbl_Trucks.TractorEmptyWeight, tbl_Trucks.[Tractor Suspension], tbl_Trucks.TractorLength, tbl_Trucks.[Tractor Gross Weight], tbl_Trucks.TrailerUnitNo, tbl_Trucks.TrailerPrice, tbl_Trucks.[Trailer Purchase Date], tbl_Trucks.TrailerYear, tbl_Trucks.Trailermake, tbl_Trucks.TrailerVIN, tbl_Trucks.TrailerAxles, tbl_Trucks.TrailerEmptyWeight, tbl_Trucks.[Trailer Suspension], tbl_Trucks.TrailerLength, tbl_Trucks.OverallLength, tbl_Trucks.TractorNoUnitstobeHauled, tbl_Trucks.TrailerNoUnitstobeHauled, tbl_Trucks.TotalNoUnitstobeHauled, tbl_Trucks.[Fuel Type], tbl_Trucks.[Fuel Capacity], tbl_Trucks.[Tractor Type], tbl_Trucks.[Tractor Body Structure], tbl_Trucks.[TRL Width], tbl_Trucks.[Trailer Type], tbl_Trucks.[Trailer Body Structure], [tbl_Owner Operators].HireDate, [tbl_Documentation Checklist].[Articles of Incorporation (CDA)], [tbl_Documentation Checklist].[Authorization Letter (CDA)], [tbl_Documentation Checklist].[Annual Inspection (CDA)], [tbl_Documentation Checklist].[Purchase Info (CDA)], [tbl_Documentation Checklist].[Cargo Insurance Election Form (CDA)], [tbl_Documentation Checklist].[Escrow Account (CDA)], [tbl_Documentation Checklist].[Fuel Card Form], tbl_Addresses.OwnerAddress1, tbl_Addresses.OwnerAddress2, tbl_Addresses.City, tbl_Addresses.State, tbl_Addresses.ZipCode, tbl_Trucks.DriverforOwner, [tbl_Owner Operators].PrimaryPhone, [tbl_Owner Operators].UserID, [tbl_Owner Operators].PayrollID, [tbl_Owner Operators].[Client ID], [tbl_Owner Operators].NewHire, [tbl_Owner Operators].Replacement, [tbl_Owner Operators].Active, [tbl_Owner Operators].[Start Date], [tbl_Owner Operators].FirstHaulDate, [tbl_Owner Operators].Transfer, [tbl_Owner Operators].TransferDate, [tbl_Owner Operators].Terminated, [tbl_Owner Operators].TerminationDate, [tbl_Owner Operators].PayType, [tbl_Owner Operators].CargoInsurance, [tbl_Owner Operators].PaymentMethod, [tbl_Owner Operators].[Record Added], [tbl_Owner Operators].[Re-Hire], [tbl_Owner Operators].[Re-Hire Date], [tbl_Owner Operators].Addendum, [tbl_Owner Operators].[Signed Contract], [tbl_Owner Operators].[ELD Install Date], [tbl_Owner Operators].[Option A], [tbl_Owner Operators].[Bonus Eligible], [tbl_Owner Operators].[Option B], [tbl_Owner Operators].[Option C], [tbl_Owner Operators].[Date Modified], [tbl_Owner Operators].[Insurance Contract], [tbl_Owner Operators].[ELD Active], [tbl_Owner Operators].[ELD Bonus Paid Date], tbl_Addresses.[Active Address], tbl_Trucks.Inactive, [tbl_Fleet Drivers].[First Name], [tbl_Fleet Drivers].[Last Name], [tbl_Fleet Drivers].[Fleet Driver], [tbl_Fleet Drivers].CoDriver, [tbl_Fleet Drivers].Birthdate, [tbl_Fleet Drivers].Active
FROM tbl_terminals INNER JOIN (tbl_Regions INNER JOIN (((([tbl_Owner Operators] LEFT JOIN [tbl_Documentation Checklist] ON [tbl_Owner Operators].ID = [tbl_Documentation Checklist].[EmployeeID]) LEFT JOIN tbl_Addresses ON [tbl_Owner Operators].ID = tbl_Addresses.EmployeeID) LEFT JOIN [tbl_Fleet Drivers] ON [tbl_Owner Operators].ID = [tbl_Fleet Drivers].EmployeeID) LEFT JOIN tbl_Trucks ON [tbl_Owner Operators].ID = tbl_Trucks.EmployeeID) ON tbl_Regions.RegionID = [tbl_Owner Operators].Region) ON tbl_terminals.TerminalID = [tbl_Owner Operators].Terminals
WHERE ((([tbl_Owner Operators].Active)=Yes) AND ((tbl_Addresses.[Active Address])=Yes) AND ((tbl_Trucks.Inactive)=No));
[/MENTION]
It will not let me add any attachments.
Only the SQL code.
Bottom line - I have a main table "tbl_Owner Operator". There are several tables that link back to this table, and they all have a one-to-many relationship. For the "tbl_Trucks" and "tbl_Fleet Drivers", I need to pull information from each of these. Now, they don't link back together, but they each link to "tbl_Owner Operator" via ID (EmployeeID in tbl_Trucks & tbl_Fleet Drivers).
I have used Inner Joins to pull all the data, and up until now, it was working great. If there is an Owner/Operator listed in the "tbl_Owner Operator" and that Owner has 5 trucks, then there are 5 entries in "tbl_Trucks". Now, if that Owner also has 5 fleet drivers, driving for him, they are listed under "tbl_Fleet Drivers", and there will be an entry for each driver. The drivers are not associated with the trucks.
I need to pull a query using these tables, but not have the query list the Owner/Operator 25 times. (trucks 12345, 56789 and drivers John Doe, Santa Claus).
Run query - will list Owner/Operator, then truck 12345 with driver John Doe. Next line, will list Owner/Operator, then truck 12345 with driver Santa Claus. Next line, lists Owner/Operator with truck 56789 and driver John Doe. Next line, lists Owner/Operator, with truck 56789 and driver Santa Claus. That is not what I'm looking for.
It should list the Owner/Operator with all of his/her trucks, and all of his/her drivers.
I can do a query with either the trucks or the drivers, and it works fine. It's when I try to combine it.
Any help would be very much appreciated!