Argument Not Optional - Why Not???

txgeekgirl

Registered User.
Local time
Today, 11:45
Joined
Jul 31, 2008
Messages
187
I have checked the boards - but nothing quite like mine and I am stuck. Any help is much appreciated! :)

This is happening on a Function call that accepts two arguments.

Call from the VBA Form to Function - (it's the SendEmail)

Code:
If MsgBox("Is this correct? " & vbNewLine & MyRequest, vbYesNo, "CARE Request") = vbYes Then
            SubmitEmail (MyRequest & "," & CStr(myRec))
            MsgBox "Your request has been sent to Information Systems for processing."
            clearform
        Else
            OpenForCare
        End If

SendEmail Function in the Global Module:

Code:
Public Function SubmitEmail(msg, rec) As String
 
You don't use quotes around the comma:

SubmitEmail (MyRequest & "," & CStr(myRec))


should be

SubmitEmail (MyRequest , CStr(myRec))

By concatenating the comma in you have created ONE parameter instead of the two you desire.
 
Hey Bob - I had tried that and got a compile error Expected: = which is why even though it looked so wrong, concatenating the comma took the error away. So I went with it.

One argument pass works fine with either one - but both and it's jacking up my code.

Do you know why it might be wanting some kind of equation?
 
Hey Bob - I had tried that and got a compile error Expected: = which is why even though it looked so wrong, concatenating the comma took the error away. So I went with it.

One argument pass works fine with either one - but both and it's jacking up my code.

Do you know why it might be wanting some kind of equation?

Sorry, when you are calling a procedure you either need to use the keyword CALL with it to keep the parens or you can call it without the parens. If you have a function on the right hand side of an equals sign you can use the parens. So, if you have something like

MyVar = FunctionName(something, somethingelse)

that is okay.

So for yours you can either go with:

Call SubmitEmail (MyRequest , CStr(myRec))

or

SubmitEmail MyRequest , CStr(myRec)
 
put the cursor over the SubmitEmail, where you call the function, and press shift-F2

this will jump to the bit of code it is actually using.

Maybe you have another SubMitEmail function that is really getting called.
 
Thanks so much Bob - went with the Call and it ran fine.

Gemma - learned a long time ago - never name your Functions anything similar. :)
 

Users who are viewing this thread

Back
Top Bottom