Hi
This could be for several forums (queries, sql) but VB seems best...
What I have is a form (frmNewMailGroup) bound to table (tblMailingGroup) in which the user chooses to add a new record, names the new mail group and some other details and it is assigned an ID (MailGroupID). They then open a query (qryBuildNewGroup) to choose who is included in the new mail group - having built the list they save and close the query (back to frmNewMailgroup) and click a button to write into a junction table tblMailgroupMembers the following data - (DISTINCT) personID from the query and MailgroupID from the form .
The problem I have is incorporating the two different data sources - how do I incorporate the MailGroupID into
INSERT INTO tblMailGroupMembers(PersonID, MailgroupID) SELECT DISTINCT personID FROM qryBuildNewMailgroup...
I also tried including the MailGroupID as a field in the qryBuildMailGroup ([Forms]![frmNewMailGroup]![MailGroupID]) but it seems to read it as a null value. I currently have a VB variable intNewGroupID = [Forms]![frmNewMailGroup]![MailGroupID] which has the correct value but can't figure how to include this in the SQL.
Any suggestions???
Many thanks
Steve
This could be for several forums (queries, sql) but VB seems best...
What I have is a form (frmNewMailGroup) bound to table (tblMailingGroup) in which the user chooses to add a new record, names the new mail group and some other details and it is assigned an ID (MailGroupID). They then open a query (qryBuildNewGroup) to choose who is included in the new mail group - having built the list they save and close the query (back to frmNewMailgroup) and click a button to write into a junction table tblMailgroupMembers the following data - (DISTINCT) personID from the query and MailgroupID from the form .
The problem I have is incorporating the two different data sources - how do I incorporate the MailGroupID into
INSERT INTO tblMailGroupMembers(PersonID, MailgroupID) SELECT DISTINCT personID FROM qryBuildNewMailgroup...
I also tried including the MailGroupID as a field in the qryBuildMailGroup ([Forms]![frmNewMailGroup]![MailGroupID]) but it seems to read it as a null value. I currently have a VB variable intNewGroupID = [Forms]![frmNewMailGroup]![MailGroupID] which has the correct value but can't figure how to include this in the SQL.
Any suggestions???
Many thanks
Steve