Access 2002
Can someone help me fix this problem?
In a form module I have a
Private Sub addReplacementKey(key_chain_id As Long, unique_id As Long)
The compiler does not seem to realize that the sub has two parameters.
When I call the sub (from code behind a button) as
addReplacementKey (key_chain_id, unique_id)
the compiler colors it red. When I call the function as
addReplacementKey (key_chain_id)
it compiles okay. Not only do I not understand why it is doing this,
but, more importantly, what should I do about it?
- Paul Schrum
John Vinson - 13 Dec 2005 00:36 GMT
>Access 2002
>
[quoted text clipped - 15 lines]
>it compiles okay. Not only do I not understand why it is doing this,
>but, more importantly, what should I do about it?
Try removing the blank before the left parenthesis. It may also be
necessary to recompile the project (if you haven't done so already),
or perhaps even to Decompile and recompile it.
John W. Vinson[MVP]
paul.schrum@gmail.com - 13 Dec 2005 00:48 GMT
> recompile the project
> decompile and recompile it
Would I find these in help? (I haven't checked yet.) In other words,
how do I do either of those.
- Paul
John Vinson - 13 Dec 2005 03:55 GMT
>> recompile the project
>
[quoted text clipped - 4 lines]
>
>- Paul
Sounds like Douglas has the right answer (and I learned something
tonight, thanks Douglas!)
To compile, open the VBA editor and select Debug... Compile <database
name> from the menu. I would recommend doing this EVERY SINGLE TIME
you edit code, before attempting to run it.
To decompile you need to use the only-recently documented /decompile
runtime switch:
http://support.microsoft.com/default.aspx?scid=kb;en-us;819780
John W. Vinson[MVP]
Douglas J. Steele - 13 Dec 2005 00:48 GMT
To invoke a subroutine, you need to either leave the parameters out of
parentheses, or use the Call keyword:
addReplacementKey key_chain_id, unique_id
or
Call addReplacementKey (key_chain_id, unique_id)
It's a fluke that it works with a single parameter: IIRC, putting a single
parameter in parentheses changes the meaning from ByVal to ByArg (or vice
versa)

Signature
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)
> Access 2002
>
[quoted text clipped - 17 lines]
>
> - Paul Schrum