ByRef argument type mismatch

S

Scott

I'm getting a "ByRef argument type mismatch" error when I call my function
from the IMMEDIATE WINDOW as below. I use syntax like this all the time in
my ASP web pages, but Access doesn't like my ByRef syntax.

What is wrong with my declaration of ByRef variables below? The variables
sReport and sReportName are empty when I call this function and I just wish
the return them equal to my test values.


CODE **********

Public Function GetNamesTest(ByVal myID As Integer, ByRef sReport As String,
_
ByRef sReportName As String)

sReport = "test1"
sReportName = "test2"

Debug.Print sReport
Debug.Print sReportName

End Function



IMMEDIATE WINDOW ********

Call GetNamesTest("14", sReport, sReportName)
 
R

RoyVidar

Scott wrote in message said:
I'm getting a "ByRef argument type mismatch" error when I call my
function from the IMMEDIATE WINDOW as below. I use syntax like this
all the time in my ASP web pages, but Access doesn't like my ByRef
syntax.

What is wrong with my declaration of ByRef variables below? The
variables sReport and sReportName are empty when I call this function
and I just wish the return them equal to my test values.


CODE **********

Public Function GetNamesTest(ByVal myID As Integer, ByRef sReport As
String, _
ByRef sReportName As String)

sReport = "test1"
sReportName = "test2"

Debug.Print sReport
Debug.Print sReportName

End Function



IMMEDIATE WINDOW ********

Call GetNamesTest("14", sReport, sReportName)

Sorry to be so blunt, but isn't this of pure academic interest?

I mean, this construct works when calling from other functions or subs,
doesn't it? And you're not going to go around running your whole app
from the immediate pane, are you ;-)

Whether it is because you can't really pass values by reference from
the
immediate pane, or that the variables are perceived to be variants and/
or Null at the time of passing - neither of which is received very
entusiastically when the function header specifies string, or something
entirely else, shouldn't really matter should it ;-)

I think, if you really want to call/test it from the immediate pane,
try
passing them by value in stead, the syntax would be for instance

Call GetNamesTest("14", (sReport), (sReportName))

or

GetNamesTest "14", (sReport), (sReportName)

Ensure they are either "" or contains text prior to calling the
function.

Else, just create a small testsub where you declare those to variables
as string, and do the testing there.
 

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