Argument Not Optional - Unable To Find Specific Case Like This


Joined
Oct 15, 2013
Messages
2
Reaction score
0
I am receiveving the "Argument Not Optional" error when clicking a button (in a database I've made)

I've seen other examples of this error message on this forum but none that I can seem to apply directly to my own situation.

The button click is supposed to open an email template (which it does), attach an Excel file (which it does) and populate the email with specific information from the form. (me.xyz for example)

BUT,

I am having an issue populating one piece of info. I have posted the code below and highlighted 4 parts.

The green part (" & Me.Section & ") is code which, when added, seems to throw the whole thing off and I get the error message (ie. it works if I do not add the green text in)

BUT

The red text (Me.REFERENCE) is the actual cause of the error, and is what the compile command gets stuck on. If I delete the red text, then it crashes when it gets to the blue text instead. (Me.INVOICE_TOTAL)

I delete the Blue text and it crashes on the Orange text (Me.CUSTOMER_NAME) (and so on)

I am also deleting the extra & vbCrLf & parts in between, but the debug specifies the Me.FIELDNAME parts as the issue (i.e it doesn't highlight the preceeeding or succeeding & vbCrLf & vb CrLf bits)

The stars (********) are phrases that were considered sensitive info and probably shouldn't be posted on here.


Private Sub Command124_Click()
Dim OLApp As Outlook.Application
Dim OLMsg As Outlook.MailItem

Set OLApp = New Outlook.Application
Set OLMsg = OLApp.CreateItem(olMailItem)

With OLMsg
.Display
.To = ""
.CC = ""
.Subject = "Expense Invoice Query Ref Doc: " & Me.REFERENCE
.Body = "Please refer to the document number showing a recent expense invoice allocated to your branch." & vbCrLf & vbCrLf & _
"Account: " & Me.ACCOUNT & vbCrLf & vbCrLf & "Supplier: " & Me.CUSTOMER_NAME & vbCrLf & vbCrLf & "£ " & Me.INVOICE_TOTAL & vbCrLf & vbCrLf & "Document: " & Me.REFERENCE & vbCrLf & vbCrLf & _
"You will be aware that the company has a procedure by which it aims to adhere to any statutory requirements for example ********." & vbCrLf & vbCrLf & _
"Please refer to section " & Me.Section & " of ********." & vbCrLf & vbCrLf & _
"Please complete and return the attached excel sheet and provide necessary details of customer account, staff names, ********, customer names and detailed description of expense." & vbCrLf & vbCrLf & _
"Please be aware that if all required details are not submitted, you may incur the ******." _
& vbCrLf & vbCrLf & "This is a new procedure which is in line with ********" & vbCrLf & vbCrLf & _
"Please EMAIL the completed form to ********, we cannot accept information over the phone" & vbCrLf & vbCrLf & _
"Many Thanks" & vbCrLf & vbCrLf & "Reconciliation /Audit Department"
.Attachments.Add "C:/tmp/Tax Reporting Form.xlsx"

' .Send <--- Uncomment this to send the email

End With
Set OLMsg = Nothing
Set OLApp = Nothing
End Sub

As I say, if I remove this bit: " & Me.Section & " then the whole thing runs like clockwork

I'd like to be able to successfully add that one last field from the form Me.Section without pulling out any of my luxurious hair......

Thanks
 
Ad

Advertisements


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top