473,407 Members | 2,315 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Passing an Object (VBA Question)

Hi All,

I have the current Sub Procedure in a VBA Module.

-----------------------------------------------------------------------------------------------------------------------------
Sub openForm(formName As String, Optional varToSend As Object)
If varToSend Is Missing Then
DoCmd.openForm formName
Else
DoCmd.openForm formName, , , , , , varToSend
End If
End Sub
----------------------------------------------------------------------------------------------------------------------------
>From a button on "frmDash" I call: openForm("frmEmployeeAdjust") -
This Works Great

But when I call: openForm("frmEmployeeAdjust",empNo) - I get an Error
"Expected: = "

I know I could just write the code in the button and everything would
work, but I would like to write this simple function that I could call
anytime I needed to open a form. I always thought Object was generic
enough to contain any data type that exists, so I should be ok weather
I pass an Integer, String, Etc. Am I doing something blantantly wrong
here?
As always, Thanks in advance for all of your help!

Feb 28 '07 #1
3 4109
Remove your brackets after "OpenForm". VBA Compiler thinks you're
calling a function.

On Feb 28, 2:42 pm, "Matt" <mdw233...@yahoo.comwrote:
Hi All,

I have the current Sub Procedure in a VBA Module.

---------------------------------------------------------------------------*--------------------------------------------------
Sub openForm(formName As String, Optional varToSend As Object)
If varToSend Is Missing Then
DoCmd.openForm formName
Else
DoCmd.openForm formName, , , , , , varToSend
End If
End Sub
---------------------------------------------------------------------------*-------------------------------------------------
From a button on "frmDash" I call: openForm("frmEmployeeAdjust") -

This Works Great

But when I call: openForm("frmEmployeeAdjust",empNo) - I get an Error
"Expected: = "

I know I could just write the code in the button and everything would
work, but I would like to write this simple function that I could call
anytime I needed to open a form. I always thought Object was generic
enough to contain any data type that exists, so I should be ok weather
I pass an Integer, String, Etc. Am I doing something blantantly wrong
here?

As always, Thanks in advance for all of your help!

Feb 28 '07 #2
On Feb 28, 2:42 pm, "Matt" <mdw233...@yahoo.comwrote:
>
Hi All,
I have the current Sub Procedure in a VBA Module.
---------------------------------------------------------------------------*--------------------------------------------------
Sub openForm(formName As String, Optional varToSend As Object)
If varToSend Is Missing Then
DoCmd.openForm formName
Else
DoCmd.openForm formName, , , , , , varToSend
End If
End Sub
---------------------------------------------------------------------------*-------------------------------------------------
>From a button on "frmDash" I call: openForm("frmEmployeeAdjust") -
This Works Great
But when I call: openForm("frmEmployeeAdjust",empNo) - I get an Error
"Expected: = "
I know I could just write the code in the button and everything would
work, but I would like to write this simple function that I could call
anytime I needed to open a form. I always thought Object was generic
enough to contain any data type that exists, so I should be ok weather
I pass an Integer, String, Etc. Am I doing something blantantly wrong
here?
As always, Thanks in advance for all of your help!
On Feb 28, 3:24 pm, "Jason Lepack" <jlep...@gmail.comwrote:
Remove your brackets after "OpenForm". VBA Compiler thinks you're
calling a function.
"Use of Parentheses in Procedure Calls:

It is sometimes confusing to determine when to use, or not to use,
parentheses ( ) to enclose argument lists with a VBA subroutine or
function.

For example, subroutines or functions that do not receive arguments in
VBA do not require parentheses. Otherwise, parentheses are required in
the declaration. When calling a subroutine, you can either call the
subroutine directly by name, or you may call it by using the Call
statement. When calling a subroutine directly, you never use
parentheses. When using the Call statement to call a function that
takes arguments, you must use parentheses. When using the Call
statement to call a function that does not take arguments, you do not
use parentheses."

<whew>

Feb 28 '07 #3
On Feb 28, 3:53 pm, "robert.waters" <robert.wat...@gmail.comwrote:
On Feb 28, 2:42 pm, "Matt" <mdw233...@yahoo.comwrote:
Hi All,
I have the current Sub Procedure in a VBA Module.
---------------------------------------------------------------------------**--------------------------------------------------
Sub openForm(formName As String, Optional varToSend As Object)
If varToSend Is Missing Then
DoCmd.openForm formName
Else
DoCmd.openForm formName, , , , , , varToSend
End If
End Sub
---------------------------------------------------------------------------**-------------------------------------------------
From a button on "frmDash" I call: openForm("frmEmployeeAdjust") -
This Works Great
But when I call: openForm("frmEmployeeAdjust",empNo) - I get an Error
"Expected: = "
I know I could just write the code in the button and everything would
work, but I would like to write this simple function that I could call
anytime I needed to open a form. I always thought Object was generic
enough to contain any data type that exists, so I should be ok weather
I pass an Integer, String, Etc. Am I doing something blantantly wrong
here?
As always, Thanks in advance for all of your help!

On Feb 28, 3:24 pm, "Jason Lepack" <jlep...@gmail.comwrote:
Remove your brackets after "OpenForm". VBA Compiler thinks you're
calling a function.

"Use of Parentheses in Procedure Calls:

It is sometimes confusing to determine when to use, or not to use,
parentheses ( ) to enclose argument lists with a VBA subroutine or
function.

For example, subroutines or functions that do not receive arguments in
VBA do not require parentheses. Otherwise, parentheses are required in
the declaration. When calling a subroutine, you can either call the
subroutine directly by name, or you may call it by using the Call
statement. When calling a subroutine directly, you never use
parentheses. When using the Call statement to call a function that
takes arguments, you must use parentheses. When using the Call
statement to call a function that does not take arguments, you do not
use parentheses."

<whew>- Hide quoted text -

- Show quoted text -
Whew is right ... but it helped a ton. Thanks to both of you!!!!!

Feb 28 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: andreas | last post by:
Hi there, I have the following situation: 1. DOT.NET Application is started 2. DOT.NET Application instantiates Access.Application.8 3. Opens a specified database (MDB) 4. DOT.NET...
58
by: jr | last post by:
Sorry for this very dumb question, but I've clearly got a long way to go! Can someone please help me pass an array into a function. Here's a starting point. void TheMainFunc() { // Body of...
39
by: Mike MacSween | last post by:
Just spent a happy 10 mins trying to understand a function I wrote sometime ago. Then remembered that arguments are passed by reference, by default. Does the fact that this slowed me down...
1
by: PJS | last post by:
I am trying to use a COM object which has a parameter of type Collection in VB6. .Net recognizes this collection as a VBA.Collection object. When I try creating a VBA.Collection in .Net using: ...
11
by: John Pass | last post by:
Hi, In the attached example, I do understand that the references are not changed if an array is passed by Val. What I do not understand is the result of line 99 (If one can find this by line...
13
by: Deano | last post by:
Apparently you can only do this with one value i.e Call MyAssetLocationZoom(Me!txtLocation, "Amend data") This runs; Public Sub MyAssetLocationZoom(ctl As Control, formName As String) On...
1
by: Lucy Ludmiller | last post by:
I have a class CMyObject, that I want to pass in an ActiveX event. I have not as yet found a way of passing pointers in events - any one knows how ? //PseudoCode IDL void...
9
by: Greger | last post by:
Hi, I am building an architecture that passes my custom objects to and from webservices. (Our internal architecture requires me to use webservices to any suggestion to use other remoting...
0
by: VaBa | last post by:
Hi, Need some help.. I have a VBA class module in MS ACCESS. In the same MS ACCESS app, I am calling a .NET DLL (which i have exposed as COM-visible) and passing BYREF an instance of the VBA class...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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
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
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.