I have a database that records details of a road traffic accident and name of driver.
sub-form records names of passengers.
The two tables are related with a one-to-many relationship.
I need to view all the names (Drivers and Passengers) as datasheet view and be able to tick a box to show investigation for this particular person is complete.
I have made a union query that is able to list all names as I want them.
I made a third table 'CaseComplete', to hold the additonal information.
however, when linked, I cannot add data to the third table.
My SQL knowledge ends here. :)
tbl_Accident – This lists all drivers involved in an vehicle accident
tbl_acc_Passengers – This lists all passengers associated with the driver.
CaseComplete - This table is new table common to driver and passenger with additonal information related to the person (not the incident).
MMQ_Clients: Union Query
Below is my code:
Profesisonal assistance will be greatly appreciated.
Union Query
Expand|Select|Wrap|Line Numbers
- SELECT DRV.AccidentId, DRV.ContactID, DRV.AccidentRefFinal, DRV.SolRef
- FROM tbl_Accident AS DRV
- UNION ALL SELECT PASS.AccidentId, PASS.ContactID, PASS.PassRefFinal, PASS.SolRefP
- FROM tbl_Acc_Passengers AS PASS;
Expand|Select|Wrap|Line Numbers
- SELECT C.FirstName & " " & [SurName] AS Client, MMQ_Clients.SolRef, MMQ_Clients.AccidentId, MMQ_Clients.AccidentRefFinal, CaseComplete.CaseCompleteID, CaseComplete.AccidentID, CaseComplete.FileComplete, CaseComplete.DateComplete, CaseComplete.Reason
- FROM Contacts AS C INNER JOIN (MMQ_Clients LEFT JOIN CaseComplete ON MMQ_Clients.AccidentId = CaseComplete.AccidentID) ON C.ContactID = MMQ_Clients.ContactID
- ORDER BY MMQ_Clients.AccidentId DESC;