So here's what I've got:
I have 3 separate tables (TblContactInfo and TblMailingList which hold contact information, and TblEntries with primary key ID that holds the data for each report I want to create and send). TblContactInfo holds names and corresponding email addresses (Primary key - EmailID), and TblMailingList stores which contacts are paired with which report (Primary keys - EmailID and ID).
I need to be able to loop through TblMailingList and be able to add each EmailID to a string that has a given value for the ID field.
Right now, this is what I've put together. I've somehow managed to never need to use a loop before, so the syntax is not familiar to me. LbxReportList is how the value for ID is selected.
Expand|Select|Wrap|Line Numbers
- Dim strEmailList As String
- Dim rst As DAO.Recordset
- Set rst = CurrentDb.OpenRecordset("SELECT * FROM TblMailingList "WHERE [ID] = " & Me.LbxReportList)
- Do Until rst.EOF
- strEmailList = strEmailList & rst.Fields(EmailID) & "; "
- rst.MoveNext
- Loop
- rst.Close
- Set rst = Nothing