If statement help with outlook email

GoodLife22

Registered User.
Local time
Today, 07:15
Joined
Mar 4, 2010
Messages
86
I have a button that my user will click to add data from an entry form to a table, then send an email out to my clients. I am 90% done, but stuck with one problem.

This email will go to one of two people depending on the [DEPT] field. If my user selects "ACCOUNTING" then the email will go to [Email1] BUT if they add anything other than "ACCOUNTING" the email will go to [EMAIL2]

Right now no matter what I put in my drop down the new email will have [EMAIL2]

Code:
   With objOutlookMsg
   .BodyFormat = olFormatHTML

    If (Me![Dept]) = ACCOUNTING Then
        Set objOutlookRecip = .Recipients.Add(Forms![frm_MAIN]![frm_SUBFORM_MAIN]![EMAIL1])
        Else 
        Set objOutlookRecip = .Recipients.Add(Forms![frm_MAIN]![frm_SUBFORM_MAIN]![EMAIL2])
    End If

    objOutlookRecip.Type = olTo

    .Subject = "We have entered the following information for your account"


What am I doing wrong here? Thanks.
 
I imagine that, as you have it, the code is comparing me.dept to a variable called ACCOUNTING

Therefore,

If (Me![Dept]) = ACCOUNTING Then

should read

If (Me![Dept]) = "ACCOUNTING" Then
 
MAN!!! It is always something small that I overlook. THANK YOU Peter, that fixed it within seconds. Thank you again.
 

Users who are viewing this thread

Back
Top Bottom