By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,327 Members | 1,789 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,327 IT Pros & Developers. It's quick & easy.

Calling a Function

P: n/a
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
Share this Question
Share on Google+
2 Replies


P: n/a
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

P: n/a
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.