PDA

View Full Version : VBA Errors



nepotist
09-30-2010, 06:17 AM
Hello guys,

I developed a Access based application and ArcGIS application with VBA. Well everything at my end on my machine worked perfectly fine and even on my colleagues machine.

When we were at the clients place, one error popped up few time and it said something in this lines
"Could not find the project or library". I thought it had to do something with the reference and I checked everything related to VBA and still it wouldn't work.

For example a simple function like "CurDir or CurDir$" showed errors similat to above. Then I thought I would code it at my clients place. When I used the ittlicense i could see all these functions available for use.

and one portion of my application gave me a error at the start of the line "Public function......"

Can someone help in figuring it out as to what is the reason for this issue. Well will working for them on few more projects and dont want to sound stupid in front of them again.

Thanks for the help guys

hansup
09-30-2010, 06:41 AM
one error popped up few time and it said something in this lines
"Could not find the project or library". I thought it had to do something with the reference and I checked everything related to VBA and still it wouldn't work.

For example a simple function like "CurDir or CurDir$" showed errors similat to above. On the problem machine, open the VBE editor and check Tools->Refererences. If any of your project's references are missing, Access gets confused and even a basic function like Left() can fail.

You should also try Debug->Compile on the problem machine to make sure you have no compiler errors.

nepotist
09-30-2010, 07:12 AM
Hansup, I did check for references.. The main reference here I believe is the Microsoft Visual Basic Extension 5.3. It had a reference to it and when it dint worked I even checked the reference to ever single microsoft vscripting extension adn still it dint work . I had to hard code the paths to files and I hated it

hansup
09-30-2010, 07:24 AM
Hansup, I did check for references.. The main reference here I believe is the Microsoft Visual Basic Extension 5.3. Is it listed as Microsoft Visual Basic for Applications Extensibility 5.3? Why do you need that one?


It had a reference to it and when it dint worked I even checked the reference to ever single microsoft vscripting extension adn still it dint work . I had to hard code the paths to files and I hated itI don't understand. Visual Basic for Applications Extensibility is not related to VBScript.

What does Debug->Compile on the problem machine tell you?

nepotist
09-30-2010, 07:32 AM
Why do you need that one?

Cause I am using VBA.



What does Debug->Compile on the problem machine tell you?

I am not sure, I had this problem yesterday to solve it, I first tired to reinstall the VBA available in the support folder (ArcGIS installation folder). Then check the reference with my machine and theres and finally I hard coded the paths.
I did not try the Debug-->Complie option :(

On a side note.. I transferred my application on to there machine.. shouldn't the references be intact??

hansup
09-30-2010, 08:08 AM
Cause I am using VBA. But Microsoft Visual Basic for Applications Extensibility 5.3 is not required for VBA. The Extensibility features allow you to use VBA code to do other operations like examine, and even modify, code modules.

I suggest you uncheck that reference, then try Debug->Compile to see what breaks. You can add it back again if needed.


I am not sure, I had this problem yesterday to solve it, I first tired to reinstall the VBA available in the support folder (ArcGIS installation folder). Then check the reference with my machine and theres and finally I hard coded the paths.
I did not try the Debug-->Complie option :(

On a side note.. I transferred my application on to there machine.. shouldn't the references be intact??I don't understand your situation. You lost me when you said you reinstalled the VBA in the ArcGIS installation folder. I have no idea what that means.

I still think Debug->Compile on the problem machine could be useful to figure out what's going on.

nepotist
09-30-2010, 08:31 AM
I don't understand your situation. You lost me when you said you reinstalled the VBA in the ArcGIS installation folder. I have no idea what that means.


When you install ArcGIS usually our clients dont install VBA component of it unless they need it.

Though the clients machine has it installed.. I reinstalled it just to make sure it the installation wasnt a problem.

As I said I did not run the Debug-Compile while I had access to clients machine..
This is what I did : After I transferred my application from DVD to clients local drive, and start testing the tools that I developed.
the first tool gave a error message like I said before "Could not find the object or library",
Then I enter the VBA Environment and placed a break point and see the error was and it highlighted "CurDir$()" with the same error message. and most of the error messages were due to this CurDir$() function. That is why I hard coded paths back.
There is one unsolved error that highlights the "Pubilc function.." with the same error message.

I understand you are suggesting that, I run a debug-compile to find out what is happening, but in short I cant as I do not have access to it anymore and I trying to find out as much information as possible. I want to do as much research as possible before I give them a call or visit them again.

Two more question
1) When I copied over my files to there machine, dont the reference get transferred along with my application?

2) If the answer to the above question is "No", then is there a way that I check for the required reference and make sure all of them are referred before they launch the application?

Thanks for being so patient.

hansup
09-30-2010, 09:03 AM
Two more question
1) When I copied over my files to there machine, dont the reference get transferred along with my application
Any references you've selected (Tools->References) in your application will still be selected in the copy of your application which is installed on the client's machine. However, that doesn't mean the resource (DLL, type library, etc.) required by the reference actually exists on the client's machine ... or that it is present in the same path as on your machine when you selected the reference. Furthermore, if one of your references is something like a proprietary ArcGIS DLL, you may have to register it on the client machine in order for it to be available to your Access application.


2) If the answer to the above question is "No", then is there a way that I check for the required reference and make sure all of them are referred before they launch the application?This procedure will notify you about any references Access thinks are broken. Perhaps you can adapt it for your application's startup routine.

Public Sub CheckReferences()
Dim ref As Reference
For Each ref In References
If ref.IsBroken Then
MsgBox "Reference " & ref.Name & " is broken!", vbCritical
End If
Next ref
Set ref = Nothing
End Sub

Imdabaum
09-30-2010, 09:10 AM
Hansup, that's an incredible piece of code you have there. Sometimes necessity is the mother of invention. I've never needed that as my applications don't really interact that much with other references aside from other Office products. But this concept will certainly come in handy.

hansup
09-30-2010, 09:20 AM
Yeah, necessity is a mother ...:eek:

I changed my basic approach to avoid adding references. I think I only have the basic 3: VBA, Access, and DAO. Maybe OLE automation, too. Then I use late binding for everything else in production applications. That way, I don't encounter any problems with missing/broken references. Life is better since I adopted that approach.:cloud9:

nepotist
09-30-2010, 10:40 AM
Well I should probably get my hands on the debug compile error in a few hours. I will post it if I cant figure out.

thanks for the code hansup, I think you should probably write an article on this issue, I am sure it will be usefull for every one.

Once again thank you

hansup
09-30-2010, 11:12 AM
I think you should probably write an article on this issue, I am sure it will be usefull for every one.

See what Doug Steele says about Access Reference Problems:
http://www.accessmvp.com/DJSteele/AccessReferenceErrors.html

I don't have anything to add.

nepotist
10-01-2010, 07:30 AM
The debug Compile gives me nothing.. (it does not show any messages)

I dont have a clue now, what needs to be done next?

hansup
10-01-2010, 07:41 AM
That's disappointing news. And surprising ... I don't understand how the application can compile without errors, yet throw an error at run-time with the CurDir function.

I'm about out of clues now, too. I have heard that you can confuse Access VBA by using reserved words as procedure and/or macros names. Allen Browne has page for Problem names and reserved words in Access:
http://allenbrowne.com/Ap****ueBadWord.html

He also has a Database Issue Checker Utility, which you could use to examine your application for name (and other) problems.
http://allenbrowne.com/Ap****ueChecker.html

However, I'm not at all confident those suggestions will resolve your problem.

Edit: Those links got mangled, and I can't seem to fix them. Go to allenbrown.com, then the tips page and find "Database Issue Checker" and "Problem names and reserved words" under the Utilities heading.