PDA

View Full Version : Macros Not Available ??



MWE
07-01-2006, 06:03 PM
The original title to this was Macros Not Available, but the word macro has a special meaning in Access, so I retitled it to be more accurate (?).

It seems like I am constantly asking questions like this about Access, ...

I have an Access2000 application that uses a single database file. There are several forms, each form has a half dozen or so VBA procedures tied to command buttons on that form. There are also 3 VBA modules with "general" code.

I recently changed a few lines of code in one sub in the code module associated with Form A. After the change, clicking on the relevant command button generated an error message indicating that the sub or function called was not defined. I thought perhaps I had inadvertenly changed the sub's name, but that was not true. So I tried other command buttons on the same form -- when any button on Form A was clicked, the error message appeared indicating that the sub or function called was not defined. :dunno The other Forms seem to work OK.

I checked several buttons to ensure that they were properly linked to the correct code. In particular, when in properties for a given commend button, clicking on the builder button for the OnClick property takes me to the correct procedure; so at least at that point, the linkage is correct.:banghead:

I exited (saving stuff as I did), restarted the appl -- same problems. I rebooted and restarted the appl -- same problems.

I had a very similar problem a few months ago. I got a bit of help here (more sympathy than actual help). Based on logic so silly I will not recount it, I tried logging onto the computer as various other people and played with the application. Suddenly the problem disappeared and did not reappear until today (even though I have worked with that code dozens of times since). Rather than relying on magic, I would like to understand what is really happening and why Access does not recognize the procedures in this one form. Is there some place one needs to tell Access that the code is "valid"?

Any help would be appreciated.

geekgirlau
07-01-2006, 08:00 PM
First step is to repair the database, as this is definitely not normal behaviour. The second step (if No. 1 is not successful) is to create a new database and import all of your objects from the old database.

Access does have some less than endearing qualities, so take it as a given the sympathy is also provided ...

asingh
07-01-2006, 11:42 PM
I faced a similiar problem with access. It was not at the CODE level, but access would not recognize one of the string conversion function STRCONV in the query design mode. It would alwasy say " function not defined ". The surprising thing here was that, I was using the exactly same function in the same data base, and it was running fine...! What solved the problem for me [still not sure about the logic]...I took the whole data base..along with the linked files..put it on a separate location on my system..and re--linked all the tables/structures. It started to work then...!
What you could try here is: The code you are getting an error at: copy paste all that code onto notepad, and then delete the respective Command Button. Put another command on [a new one from the toolbox]..and just paste your code on it..that calls the subs/procedures where you are getting an error. And do a compact & repair just to be extra safe.

It just might work..again no logic here..just sympathy and some wild trouble--shooting....!


regards,

asingh

MWE
07-02-2006, 11:48 AM
First step is to repair the database, as this is definitely not normal behaviour. The second step (if No. 1 is not successful) is to create a new database and import all of your objects from the old database.

Access does have some less than endearing qualities, so take it as a given the sympathy is also provided ...
thanks; can you be a bit more specific re "repair the database". How is that done?

MWE
07-02-2006, 11:52 AM
I faced a similiar problem with access. It was not at the CODE level, but access would not recognize one of the string conversion function STRCONV in the query design mode. It would alwasy say " function not defined ". The surprising thing here was that, I was using the exactly same function in the same data base, and it was running fine...! What solved the problem for me [still not sure about the logic]...I took the whole data base..along with the linked files..put it on a separate location on my system..and re--linked all the tables/structures. It started to work then...!
What you could try here is: The code you are getting an error at: copy paste all that code onto notepad, and then delete the respective Command Button. Put another command on [a new one from the toolbox]..and just paste your code on it..that calls the subs/procedures where you are getting an error. And do a compact & repair just to be extra safe.

It just might work..again no logic here..just sympathy and some wild trouble--shooting....!


regards,

asinghThanks. It is interesting how often something like this approach seems to work. No apparent reason why, but it does.

I tried one easier step first: I moved all the vba code from Form A's code module to "someplace else" (Form A's code module is now blank); closed/saved the file; opened the file and copied the code back. I had to repair a few (but not all) of the button<>code links (?), but things seem to be working again now. I can only guess that cleaning out the code module entirely was the solution, but why that worked is not clear.

mdmackillop
07-02-2006, 01:30 PM
It's only in Excel that I've noticed it, but "Missing" references seem to cause unrelated problems. Maybe worth a quick check.
MD