Hello everyone, can someone please point out what I am doing wrong?
I have some VBA which I have attached to a button. When the button is clicked the VBA should look to see if a specific text box on a form contains "None" and if so it should open an email which pulls fields from the open form.
If the text box contains anything other than "None" then it opens a different email which pulls fields from the open form.
Both of the VBA work on thier own if attached to different buttons so I know there is nothing wrong with the actual email code.
The problem is combining them into one VBA IF statement. When I do that and click on the button it opens the debugger and highlights the ELSE statement saying "Else without If"
I have tried everything I can think of to fix this. Can you see what I am missing? I really need help!!!
I have some VBA which I have attached to a button. When the button is clicked the VBA should look to see if a specific text box on a form contains "None" and if so it should open an email which pulls fields from the open form.
If the text box contains anything other than "None" then it opens a different email which pulls fields from the open form.
Both of the VBA work on thier own if attached to different buttons so I know there is nothing wrong with the actual email code.
The problem is combining them into one VBA IF statement. When I do that and click on the button it opens the debugger and highlights the ELSE statement saying "Else without If"
I have tried everything I can think of to fix this. Can you see what I am missing? I really need help!!!
PHP:
Private Sub Image167_Click()
If Form_frmEmailSampleDelivery.Text8 = "None" Then
Dim OutApp As Object
Dim OutMail As Object
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
With OutMail
.To = "AllStaff"
.CC = ""
.BCC = ""
.Subject = "Samples Received - Unknown Project!"
.Body = Form_frmEmailSampleDelivery.Text117 & " " & "boxes of samples have been delivered but no project has been identified. The interval is from" & " " & Form_frmEmailSampleDelivery.Text113 & " " & Form_frmEmailSampleDelivery.Combo139 & " " & "to" & " " & Form_frmEmailSampleDelivery.Text114 & " " & Form_frmEmailSampleDelivery.Combo139 & ". The boxes are marked for well" & " " & Form_frmEmailSampleDelivery.Combo135 & ". Please contact Labs as soon as possible if you recognise these samples."
.Display
Else
Dim OutApp As Object
Dim OutMail As Object
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
With OutMail
.To = Form_frmEmailSampleDelivery.Text8
.CC = ""
.BCC = ""
.Subject = "Samples Received!"
.Body = "Samples have been received and booked in for " & Form_frmEmailSampleDelivery.Text9 & " - " & Form_frmEmailSampleDelivery.Text7 & ". Please log in to PIMS to review the samples and inform Labs when you require them to be listed. Please note that if the project does not have a valid purchase order then Labs will not list samples unless authorised by a Director."
.Display
End With
On Error GoTo 0
End Sub