Function Arguments

M

Martin

I have a function with one argument that is being called from another
function. In the process of testing, I decided to add a second argument to
the function. So I changed the Function statement as follows:
From: Function Test(A) To: Function Test(A,B)

When I went to the calling statement to add the second argument, Access
allowed me to add the second argument, but when I moved the cursor off the
line, I get an error message: "Compile Error, Expected =".

I have tried recreating the called function statement, changing the Function
to Sub--all with the same result.

Can someone give me an idea of what I am missing?

Thanks.
 
W

Wolfgang Kais

Hello Martin.

Martin said:
I have a function with one argument that is being called from another
function. In the process of testing, I decided to add a second argument
to the function. So I changed the Function statement as follows:
From: Function Test(A) To: Function Test(A,B)

When I went to the calling statement to add the second argument, Access
allowed me to add the second argument, but when I moved the cursor off
the line, I get an error message: "Compile Error, Expected =".
[...]

It would be easier the help if we knew the calling statement.
 
M

Martin

The original calling statement is: Test(A). The new one is: Test(A,B).


Wolfgang Kais said:
Hello Martin.

Martin said:
I have a function with one argument that is being called from another
function. In the process of testing, I decided to add a second argument
to the function. So I changed the Function statement as follows:
From: Function Test(A) To: Function Test(A,B)

When I went to the calling statement to add the second argument, Access
allowed me to add the second argument, but when I moved the cursor off
the line, I get an error message: "Compile Error, Expected =".
[...]

It would be easier the help if we knew the calling statement.
 
W

Wolfgang Kais

The original calling statement is: Test(A). The new one is: Test(A,B)

Change it to: Test A, B
Or: Test (A), (B)
Or: Call Test(A, B)

--
Regards,
Wolfgang
Martin said:
The original calling statement is: Test(A). The new one is: Test(A,B).


Wolfgang Kais said:
Hello Martin.

Martin said:
I have a function with one argument that is being called from another
function. In the process of testing, I decided to add a second argument
to the function. So I changed the Function statement as follows:
From: Function Test(A) To: Function Test(A,B)

When I went to the calling statement to add the second argument, Access
allowed me to add the second argument, but when I moved the cursor off
the line, I get an error message: "Compile Error, Expected =".
[...]

It would be easier the help if we knew the calling statement.
 
M

Martin

Thanks for the help. Any of your suggestions work. Access Help indicates
the arguments should be coded as (A,B), nor that the Call is needed as in the
following:

Function CalcSum(ByVal FirstArg As Integer, ParamArray OtherArgs())

Dim ReturnValue
' If the function is invoked as follows:
ReturnValue = CalcSum(4, 3 ,2 ,1)


I guess it is not as much "help" as I thought.

Thanks again.


Wolfgang Kais said:
The original calling statement is: Test(A). The new one is: Test(A,B)

Change it to: Test A, B
Or: Test (A), (B)
Or: Call Test(A, B)

--
Regards,
Wolfgang
Martin said:
The original calling statement is: Test(A). The new one is: Test(A,B).


Wolfgang Kais said:
Hello Martin.

:
I have a function with one argument that is being called from another
function. In the process of testing, I decided to add a second argument
to the function. So I changed the Function statement as follows:
From: Function Test(A) To: Function Test(A,B)

When I went to the calling statement to add the second argument, Access
allowed me to add the second argument, but when I moved the cursor off
the line, I get an error message: "Compile Error, Expected =".
[...]

It would be easier the help if we knew the calling statement.
 
W

Wolfgang Kais

Hello Martin.
I have a function with one argument that is being called from
another function. In the process of testing, I decided to add a
second argument to the function. So I changed the Function
statement as follows:
From: Function Test(A) To: Function Test(A,B)

When I went to the calling statement to add the second argument,
Access allowed me to add the second argument, but when I moved
the cursor off the line, I get an error message:
"Compile Error, Expected =". [...]
It would be easier the help if we knew the calling statement.
The original calling statement is: Test(A). The new one is:
Test(A,B).
Change it to: Test A, B
Or: Test (A), (B)
Or: Call Test(A, B)
Thanks for the help. Any of your suggestions work. Access Help
indicates the arguments should be coded as (A,B), nor that the
Call is needed as in the following:

Function CalcSum(ByVal FirstArg As Integer, ParamArray OtherArgs())

Dim ReturnValue
' If the function is invoked as follows:
ReturnValue = CalcSum(4, 3 ,2 ,1)

Something to keep in mind:
When using a function like sub, don't enclose the arguments in brackets.
Alternatively, "Call" the function using brackets.
When processing a return value, like with CalcSum, always use brackets (and
don't use "Call").

By the way: I guess that Your original calling statement wasn't Test(A) but
Test (A) (with a blank in between).
 

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