Hello,
I am having problems with the execution of a if/then statement and an exit sub procedure. Just cannot figure where is the mistake. I appreciate your help.
My project is to create a db to manage refunds which clients are due to my company.
Once in the main form, users will select the refund type from a combo. The refund can be total or partial.
My code creates an email and a simple text in the body after clicking on a cmdbutton.
The cmdbutton should first check if a unbound control (RatesNo) is Null. The control sets the number of rates due in the refund it Partial.
I
If is null, then the code should stop running the control RatesNo get focus so that users can add a value to it through a combobox.
If the RatesNo control is Not Null, then the code can be executed creating the email:
I am having problems with the execution of a if/then statement and an exit sub procedure. Just cannot figure where is the mistake. I appreciate your help.
My project is to create a db to manage refunds which clients are due to my company.
Once in the main form, users will select the refund type from a combo. The refund can be total or partial.
My code creates an email and a simple text in the body after clicking on a cmdbutton.
The cmdbutton should first check if a unbound control (RatesNo) is Null. The control sets the number of rates due in the refund it Partial.
I
If is null, then the code should stop running the control RatesNo get focus so that users can add a value to it through a combobox.
If the RatesNo control is Not Null, then the code can be executed creating the email:
Code:
Dim objOutlook As Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
Dim objOutlookRecip As Outlook.Recipient
Dim strBody As String
If Me.DEBTTYPE = "partial" And IsNull("Me.RemNo") Then
MsgBox "You have select the Remittance No.", vbOKOnly, "Remittance Log."
Me.RemNo.BorderColor = vbRed
Me.RemNo.SetFocus
Exit Sub
End If
If Me.DEBTTYPE = "total" Then
strBody = "Hello, this is a total refund." & vbCrLf & vbCrLf
End If
If Me.DEBTTYPE = "partial" and Not is Null (Me.RemNo) Then
strBody = "Hello, this is a partial refund.” & vbCrLf & vbCrLf
End If
' Create the Outlook session.
Set objOutlook = CreateObject("Outlook.Application")
' Create the message.
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
With objOutlookMsg
' Set the Subject, Body, and Importance of the message.
.Subject = "Debt Refund"
.Body = strBody
.To = xxxxxxx@google.com
.Display
End With
Set objOutlook = Nothing