473,487 Members | 2,601 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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 1686
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
2934
by: Muthu | last post by:
I've read calling conventions to be the order(reverse or forward) in which the parameters are being read & understood by compilers. For ex. the following function. int Add(int p1, int p2, int...
6
3294
by: jchao123 | last post by:
Dear All, I have an MDB file (Access 2000/XP) which contains generic routines I use in various apps (eg, API calls, File access classes etc). I have compiled into an MDE file which I reference...
14
2976
by: ericellsworth | last post by:
Hi, I'm trying to use a class to pass variables back and forth from a form opened in dialog mode. I have created a class which invokes a form in its show method, like so: Public Sub Show() '...
1
2880
by: Jesse McGrew | last post by:
Hi all, I'm trying to make a plugin DLL for a third-party application, using VC++ .NET 2003. This DLL acts as a bridge between the C++ plugin API of the application, and my actual plugin code...
5
3392
by: Nick Flandry | last post by:
I'm running into an Invalid Cast Exception on an ASP.NET application that runs fine in my development environment (Win2K server running IIS 5) and a test environment (also Win2K server running IIS...
2
3136
by: Geler | last post by:
A theoretical question: Sorry if its a beginner question. Here is a quote from the MSDN explaning the C/C++ calling convention.. It demonstrates that the calling function is responsible to clean...
18
4309
by: John Friedland | last post by:
My problem: I need to call (from C code) an arbitrary C library function, but I don't know until runtime what the function name is, how many parameters are required, and what the parameters are. I...
15
22788
by: dspfun | last post by:
Hi, Is it possible to print the function name of the calling function? For example, f1() and f2() both calls f3(), in f3() I would like to print the name of the function calling f3() which...
11
3167
by: briankirkpatrick | last post by:
Forgive me if my post seems a little amateurish... I'm requesting assistance from some of you smart folks out there to get the managed calls write that meet the specification in the esa.h for...
16
517
by: teju | last post by:
hi, i am trying 2 merge 2 projects into one project.One project is using c language and the other one is using c++ code. both are working very fine independently.But now i need to merge both...
0
7137
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7181
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7349
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5442
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4565
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3076
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1381
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
600
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
267
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.