B
Bam Bam
Hi all,
I have a music database with two main tables (tblArtists and tblRecordings)
joined by a junction table (tblLinkArtist_Recording) used to resolve the
many to many relationship (as an Artist can have many recordings and a
Recording(Various Artists CD for example) can have many Artists). Each
record in the junction table contains only the ArtistID and the RecordingID
as a composite primary key, no other fields. I would like to be able to
delete the associated Recordings when I choose to delete an Artist.
Assuming 'strArtistID' is holding the ArtistID of the current Artist record:
I can delete the Artist with this:
DoCmd.RunSQL "DELETE * FROM tblArtists WHERE ArtistID=" & strArtistID
And I can delete the Artist from the junction table with this:
DoCmd.RunSQL "DELETE * FROM tblLINKArtist_Recording WHERE ArtistID= " &
strArtistID
But the next command is obviously useless as tblRecordings doesn't store an
ArtistID, it is stored in the junction table:
DoCmd.RunSQL "DELETE * FROM tblRecordings WHERE ArtistID=" & strArtistID
What kind of SQL string or Query can I use to managed this deletion? Or am I
going about this in the wrong way?
Yours faithfully,
Limited Intellect (but 17 gold medals heading down under!!)
I have a music database with two main tables (tblArtists and tblRecordings)
joined by a junction table (tblLinkArtist_Recording) used to resolve the
many to many relationship (as an Artist can have many recordings and a
Recording(Various Artists CD for example) can have many Artists). Each
record in the junction table contains only the ArtistID and the RecordingID
as a composite primary key, no other fields. I would like to be able to
delete the associated Recordings when I choose to delete an Artist.
Assuming 'strArtistID' is holding the ArtistID of the current Artist record:
I can delete the Artist with this:
DoCmd.RunSQL "DELETE * FROM tblArtists WHERE ArtistID=" & strArtistID
And I can delete the Artist from the junction table with this:
DoCmd.RunSQL "DELETE * FROM tblLINKArtist_Recording WHERE ArtistID= " &
strArtistID
But the next command is obviously useless as tblRecordings doesn't store an
ArtistID, it is stored in the junction table:
DoCmd.RunSQL "DELETE * FROM tblRecordings WHERE ArtistID=" & strArtistID
What kind of SQL string or Query can I use to managed this deletion? Or am I
going about this in the wrong way?
Yours faithfully,
Limited Intellect (but 17 gold medals heading down under!!)