Append to Foreign Key?

Shepenwepet

New member
Local time
Today, 15:20
Joined
Aug 28, 2006
Messages
6
I have three tables as below, linked by a many-to-many relationship.

Contact Table
ContactID (PK-Autonumber)
Contact details...

Mailing Table
MailID (PK-Autonumber)
ContactID (FK)
NewsletterID (FK)
Details...
ynMailed

Newsletter Table
NewsletterID
Details...

My Problem: I have acquired 200 customers in one month, and I have to MANUALLY assign each bulk mailing recipient. This will not do. I've experimented with Queries to do the work for me, but keep tripping over a foreign key violation.

My Question: How can I create many records in the Mailing table with a constant Newsletter ID and whichever contacts my Select query returns? How do I populate the SECOND foreign key (the constant Newsletter ID) so I don't get the key violation?

I thought about doing a Make Table Query based on my Select Query, then an Update query to create the second foreign key, then an Append query with all the values in place. Is there an easier way?

I feel like this should be really easy, but two weeks of tinkering have gotten me nowhere. A nudge in the right direction would be greatly appreciated.
 
Thank you, Uncle Gizmo! Worked like a dream! I'm just beginning to figure out how to use queries but I like them already.

Here's the final SQL, for the record. I'm going to set up a form to select the criteria and a process that used to take ages will be instantaneous.

INSERT INTO tblMailBridge ( ContactID, NewsletterID )
SELECT Contacts.ContactID, QryAppendSrc1.NewsletterID
FROM Contacts, QryAppendSrc1
WHERE (((Contacts.ContactTypeID)=5) AND ((Contacts.[Subscription Type])="SnailMail"));
 

Users who are viewing this thread

Back
Top Bottom