Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms Programming / December 2005

Tip: Looking for answers? Try searching our database.

Compiler miscounting parameters in a private function

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
paul.schrum@gmail.com - 12 Dec 2005 23:33 GMT
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
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.