472,978 Members | 2,390 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,978 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 1669
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
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
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
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
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
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
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
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
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
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
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
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
4
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

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.