Unanswered: Forms for editing/inserting/deleting many-to-many records
I have two tables in a many-to-many relationship using a junction table. First table is "vehicles" the second table is "events". One vehicle can experience multiple events (i.e. lease, sale, crash), and the same event can happen to multiple vehicles (i.e bulk buy)
I have created a form that shows each vehicle, with a datasheet subform that shows all the events related to that vehicle. The display works great.
Now, however I would like to insert/modify/delete events related to the vehicle. For insert/modify I envision opening up a new form that contains all the information for the event. For delete, I obviously just need to push a button.
Does anyone have any good examples on how to create all of this?
Dim dbs As DAO.Database
Dim strSQL As String
strSQL = "DELETE FROM Events WHERE <Event Id> IN (SELECT <Event Id> FROM <Junction Table> WHERE <Vehicle Id> = <Desired Vehicle Id>);"
Set dbs = CurrentDb
Set dbs = Nothing
Replace the elements between brackets by their proper names or values.