I have some code I am trying to get to run that goes through a list of e-mail addresses and adds the addresses to a string based on specific criteria. What is happening is the SQL that specifically calls out a value works, but the SQL that references a form for the value does not pull the work. In other words, it doesn't add the e-mail addresses when the values match the forms.
strSQL = "SELECT tblEmail.Email FROM tblEmail WHERE ((tblEmail.LocationType = ' & [Forms]![frmAlertLog]![sfrmAlertLog].[Form]![Location] & ' Or tblEmail.LocationType = 'Warehouse') And (tblEmail.Plant = ' & [Forms]![frmAlertLog]![sfrmAlertLog].[Form]![MfgPlant] & ' Or tblEmail.Plant = 'Plymouth' Or tblEmail.Plant = 'All'));"
strEmail = ""
Set db = CurrentDb
Set rs = db.OpenRecordset(strSQL, dbOpenDynaset)
rs.MoveFirst
Do Until rs.EOF
If strEmail = "" Then
strEmail = rs!email
Else
strEmail = rs!email & ";" & strEmail
End If
rs.MoveNext
Loop
Any help would be appreciated.
John Green
strSQL = "SELECT tblEmail.Email FROM tblEmail WHERE ((tblEmail.LocationType = ' & [Forms]![frmAlertLog]![sfrmAlertLog].[Form]![Location] & ' Or tblEmail.LocationType = 'Warehouse') And (tblEmail.Plant = ' & [Forms]![frmAlertLog]![sfrmAlertLog].[Form]![MfgPlant] & ' Or tblEmail.Plant = 'Plymouth' Or tblEmail.Plant = 'All'));"
strEmail = ""
Set db = CurrentDb
Set rs = db.OpenRecordset(strSQL, dbOpenDynaset)
rs.MoveFirst
Do Until rs.EOF
If strEmail = "" Then
strEmail = rs!email
Else
strEmail = rs!email & ";" & strEmail
End If
rs.MoveNext
Loop
Any help would be appreciated.
John Green