I am trying to generate an email that is gathering information from two different tables. I keep getting an error message that it can not find my CustomerNo. Does anyone have any ideas?
Code:
Private Sub cmdEmail_Click() Dim CustomerNo As Parameter Dim ClientID As Parameter On Error GoTo Err_Email_Click stEmailTo = DLookup("[CustomerMailingsEMail]", "[Customer]", "[CustomerNo] = '" & Me![ CustomerNo] & ";" & " " _ And DLookup("[ReportMailingCC]", "[Clients]", "[ClientID] = '" & Me![ClientID]) & "'") DoCmd.SendObject acReport, stDocName, acFormatRTF, stEmailTo, , , _ "Orders" & "," & " " & DLookup("[Customer Name]", "[Customer]", "[CustomerNo] = '" & Me![CustomerNo] & "'") & "," & " " & _ DLookup("[Physical City]", "[Customer]", "[ CustomerNo] = '" & Me![ Customer No] & "'") & "," & " " & _ DLookup("[Physical State]", "[ Customer]", "[ CustomerNo] = '" & Me![ CustomerNo] & "'") & "," & " " & _ DLookup("[Physical Country]", "[ Customer]", "[ CustomerNo] = '" & Me![ CustomerNo] & "'") & " " & " CustomerNo" & " " & Me![ CustomerNo], _ DLookup("[ReportMailingInstructions]", "[Clients]", "[ClientID] = '" & Me![ClientID]) _ & vbCr & DLookup("[ReportMailingEmailText]", "[Clients]", "[ClientID] = '" & Me![ClientID]) Exit_Email_Click: Exit Sub Err_Email_Click: MsgBox Err.Description Resume Exit_Email_Click End Sub
Comment