471,119 Members | 1,408 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,119 software developers and data experts.

Calling a Function

I have limited knowledge of VBA, but I've learned a lot here. I
can't figure out how to pass 2 parameters in a sub? I call PassDate
and pass 1 date.

Public Sub PassDate()
Calculate (#7/1/2003#)
End Sub

Public Sub Calculate(var1 As Date)
'Runs Code
End Sub

Then I try:

Public Sub PassDate()
Calculate (#7/1/2003#, #7/31/2003#)
End Sub

Public Sub Calculate(var1 As Date, var2 As Date)
'Runs Code
End Sub

The "Calculate (#7/1/2003#, #7/31/2003#)" expression errors and asks
for an equal sign. How would I pass 2 parameters to another function?

Thanks.
Nov 12 '05 #1
2 1600
On 5 Mar 2004 14:20:52 -0800, bs**********@hotmail.com (neptune)
wrote:
I have limited knowledge of VBA, but I've learned a lot here. I
can't figure out how to pass 2 parameters in a sub? I call PassDate
and pass 1 date.

Public Sub PassDate()
Calculate (#7/1/2003#)
End Sub

Public Sub Calculate(var1 As Date)
'Runs Code
End Sub

Then I try:

Public Sub PassDate()
Calculate (#7/1/2003#, #7/31/2003#)
End Sub

Public Sub Calculate(var1 As Date, var2 As Date)
'Runs Code
End Sub

The "Calculate (#7/1/2003#, #7/31/2003#)" expression errors and asks
for an equal sign. How would I pass 2 parameters to another function?

Thanks.

First off you are using a reserved word Calculate as a procedure name.
Calculate is a built in method. Look it up.

But, the main problem is you are confusing sub-procedure with
functions. What you have here are all sub procedures. They do not
return values. When you call a function you wrap the arguments in
parenthesis - like you have done here. What you are calling as a
function does not return anything because it is a sub.

Take a look in help.

- Jim
Nov 12 '05 #2
If you don't want to include the Call statement, just use Calculate
#7/1/2003#, #7/31/2003#
From the Access97 help file - Call Statement

"You are not required to use the Call keyword when calling a procedure.
However, if you use the Call keyword to call a procedure that requires
arguments, argumentlist must be enclosed in parentheses. If you omit the
Call keyword, you also must omit the parentheses around argumentlist. If you
use either Call syntax to call any intrinsic or user-defined function, the
function's return value is discarded."

Mike Storr
www.veraccess.com
"neptune" <bs**********@hotmail.com> wrote in message
news:c5**************************@posting.google.c om...
I have limited knowledge of VBA, but I've learned a lot here. I
can't figure out how to pass 2 parameters in a sub? I call PassDate
and pass 1 date.

Public Sub PassDate()
Calculate (#7/1/2003#)
End Sub

Public Sub Calculate(var1 As Date)
'Runs Code
End Sub

Then I try:

Public Sub PassDate()
Calculate (#7/1/2003#, #7/31/2003#)
End Sub

Public Sub Calculate(var1 As Date, var2 As Date)
'Runs Code
End Sub

The "Calculate (#7/1/2003#, #7/31/2003#)" expression errors and asks
for an equal sign. How would I pass 2 parameters to another function?

Thanks.

Nov 12 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

8 posts views Thread by Muthu | last post: by
6 posts views Thread by jchao123 | last post: by
1 post views Thread by Jesse McGrew | last post: by
5 posts views Thread by Nick Flandry | last post: by
2 posts views Thread by Geler | last post: by
15 posts views Thread by dspfun | last post: by
11 posts views Thread by briankirkpatrick | last post: by
16 posts views Thread by teju | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.