By Ref argument type mismatch

P

Paolo

Hi all,

In one sub:

Dim wrkpack as boolean
workpack = me.wrkpack
call othersub(wrkpack)

In another sub:

Sub othersub(wrkpack as boolean)


Is this a silly thing to do? I keep on getting By Ref argument type
mismatch errors. me.workpack is a checkbox on a form with the
default=0. The reason I am using workpack as a boolean variable is
that in the second sub, I am running a transaction and I can't figure
out how to get the transaction to recognize me.wrkpack.

Thanks in advance

Paolo
 
P

Paolo

Oops never mind. I had a typo when I dim wrkpack. If any one has any
light to shed vis-a-vis transactions, I would appreciate it.
 
N

Nikos Yannacopoulos

Paolo,

The problem is that you are declaring the variable twice. Since you are
declaring it in:

Sub othersub(wrkpack as boolean)

you should not be doing so anywhere else, so remove the:

Dim wrkpack as boolean

from wherever you are calling the sub from.

HTH,
Nikos
 
P

Paolo

Hi Nikos,

Thanks for the reply. Just a follow up, though. I fixed the problem
as it was a typo when I initially declared it. If I now don't
initially declare it (in the dim statement), I get that error again.
It seems that if I don't declare it, it gets treated as a variant
right? And if I call another sub passing this variant along as a
boolean, I get an error. Is this logical?

Paolo
 
P

Paolo

Hi Nikos,

Thanks for the reply. Just a follow up, though. I fixed the problem
as it was a typo when I initially declared it. If I now don't
initially declare it (in the dim statement), I get that error again.
It seems that if I don't declare it, it gets treated as a variant
right? And if I call another sub passing this variant along as a
boolean, I get an error. Is this logical?

Paolo
 
D

Douglas J. Steele

Sorry, Nikos, but that doesn't make any sense.

While the name wrkpack may be the same in both locations, they are not the
same variable, and so should be declared twice.
 
N

Nikos Yannacopoulos

Doug,

I seem to remember I've had this problem... maybe I'm wrong, in which
case, thanks for setting the record straight.

Nikos
 
Top