strange VBA problem / bug ?

J

jfp

In the code on various forms in my project i use a Sub i wrote called
"NextMonth":
Public Sub NextMonth(ByVal Y As Integer, ByVal M As Integer, _
ByRef YNext As Integer, ByRef MNext As Integer, _
Optional ByVal Inc As Integer = 1)

1. Originally, this sub was in a module in the database. Everything
worked fine:
a) code compiles without error
b) if cursor on a call to this sub, then Shift-F2 pops up the sub
definition in the module.

2. I moved the module (and others, containing many other subs /
functions that i use) into a library and added a reference to the
library in the project. Things fail:
a) compiling gives me: "Ambiguous name detected: NextMonth" where i
call the sub
b) on that line, Shift-F2 does not take me to the alleged other
definition. Instead, i get the error "Identifier under cursor is not
recognized"

3. I deleted the module so that there is NO definition of NextMonth
anywhere -- project or library. Now,
a) code compiles without error
b) Shift-F2 does not show me where the definition is -- instead, Access
crashes (" ... encountered a problem, needs to close ...")
c) If i place a breakpoint and attempt to step into the code for
NextMonth, Access also crashes.

4. I get the same behavior even with a new database where the relevant
forms / modules have been imported from the original.

It seems that somehow the original definition of NextMonth in a module
in the database remains somewhere in the database (at least, that is,
portions of it do) and cannot be purged (database repair utility does
not help). There is, however, no similar problem with any of the other
functions / subs that were moved into the library.

I have "solved" the problem by changing the name of the sub in the
library and in all calls to it. Surely there must be a better way ?

Any ideas as to what is happening here ?
 
P

PC Datasheet

NextMonth is a reserved word which may be causing you the problem. Try changing
the name.
 
A

Arvin Meyer

The Module Name and the Procedure Name may be the same. That is no longer
acceptable. Also, from a code window, use Ctrl+F to open a find window and
search the entire project for "NextMonth". It is possible that you moved it
to 2 or more places.
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads:
http://www.datastrat.com
http://www.mvps.org/access
 
J

jfp

PC said:
NextMonth is a reserved word which may be causing you the problem. Try changing
the name.

that could certainly do strange things ... but -- i find nothing in Help
when i enter "nextmonth" (Access 2002)
Where is NextMonth noted as a reserved word ?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top