If combobox = "value" or "value" then........

You could replace the starting bit with

SQL:
    SELECT Case Me.ClientStatus
        CASE "NPW - No Contact" ,"NPW - Gone Elsewhere" ,"NPW - Unable to Place"
             If MsgBox("Would you like to send a refund request for this lead?", vbQuestion + vbYesNo + vbDefaultButton1, "Request refund?") = vbNo Then Exit Sub
   
        CASE ELSE
            EXIT SUB
    END SELECT
   
    Dim appOutlook         As Outlook.Application
    Dim MailOutlook     As Outlook.MailItem
    Dim strSQL             As String
    Rest of code goes here.....
 
You have good replies from Arnel and Minty regarding your logic - I might have done it with a different variation, but don't want to confuse the issue!

(Actually, Minty might have mixed up the commands in his case blocks).

But a separate question: is there any reason why you set the Outlook.Application within the Do While Not loop?
Code:
' ...
Do While Not clientRST.EOF
    Set appOutlook = CreateObject("Outlook.application")   <-- Why inside the loop ???
    Set MailOutlook = appOutlook.CreateItemFromTemplate(Application.CurrentProject.Path & "\RefundRequest.oft")
' ...

I think it would be more efficient just to set it one time outside the loop:
Code:
' ...
Set appOutlook = CreateObject("Outlook.application")
Do While Not clientRST.EOF
    Set MailOutlook = appOutlook.CreateItemFromTemplate(Application.CurrentProject.Path & "\RefundRequest.oft")
' ...
    Set MailOutlook = Nothing
    clientRST.MoveNext
Loop
clientRST.Close
Set clientRST = Nothing
Set appOutlook = Nothing
' ...
 
@cheekybuddha If I'm honest cant really answer your question 😊 because I have pieced this code together slowly from other bits of code I have found elsewhere. so it is in this order because that's the way it was when I copied it!
 

Users who are viewing this thread

Back
Top Bottom