I am using a DLookup to capture an e-mail address as a variable in my code. Then I use the e-mail address when I generate an e-mail with an attached report. My problem occurs when the e-mail address I am looking for does not yet exist. I tried using IsError with my Dlookup in an If statement, but I keep getting a "Data Type Mismatch" error, instead of the code going to my condition. I also tried IsMissing with the same results. I also tried to add a Try-Catch block, but was unable to use that logic in Access. How can I get this to work?
Here is the code I have now (EmailAddr is a string variable declared at the beginning of the sub. BinName is also a string variable declared earlier.):
Any assistance you can provide would be greatly appreciated.
Here is the code I have now (EmailAddr is a string variable declared at the beginning of the sub. BinName is also a string variable declared earlier.):
Code:
If IsError(DLookup("EMAIL", "EMAIL_TBL", "CStr(BIN) = " & BinName)) = True Then
EmailAddr = InputBox("Tech e-mail not on file. " & Chr(13) & "Please enter the Tech's e-mail address for this bin.", "E-mail Not On File")
Else
EmailAddr = DLookup("EMAIL", "EMAIL_TBL", "CStr(BIN) = " & BinName)
End If
Any assistance you can provide would be greatly appreciated.