Solved

method '~' of object '~' failed

Posted on 2011-03-21
6
527 Views
Last Modified: 2012-05-11
Hello,

I am getting exactly the same symptoms as described on this page
http://www.experts-exchange.com/Programming/Languages/Visual_Basic/Q_10217009.html
however the advice is a little out of date

The program I have written is in VB6 and connects to an A2k3 database. It works fine on the development system but on transferring it onto a client system which has office 2k7 installed I find the error message upon any attempt to connect to the db.

I presume there is some kind of DAO dll/ocx involved which is different between 2k3 and 2k7, can anyone advise?

Thanks
0
Comment
Question by:daz84
6 Comments
 
LVL 119

Expert Comment

by:Rey Obrero
ID: 35182411
see this link for different connection config to A2007 db.

http://www.connectionstrings.com/access-2007
0
 
LVL 84
ID: 35182512
How does your VB6 program connect to the database? If you're using ADO, then cap's advice should work. If not, you'll need to let us know how the connection is being made.
0
 
LVL 11

Accepted Solution

by:
kbirecki earned 300 total points
ID: 35188266
I've seen this strange error myself.  I, too, still use some Access 2002/2003 databases.  In my case, I narrowed it down to corruption in the database.  Unfortunately, compact and repair did no good in those cases.  That only gave me a false sense of confidence that the db was fine - it wasn't.  Here's one suggestion: create a clean A2K3 database from scratch, and put one table in it, then try your test of connecting from VB6 to that new db.  Run your tests with those two files (the vb6 test app and the clean A2K2 db, both with non content of your legacy or suspect app or db) on different systems and see if you still get the problem or not.  (You probably won't.)  If you don't get the problem, then that would be an indication of some "corruption" in the A2K3 db, even though it works on the development system.  If you do get the problem, then the problem is outside the environment of the VB6 and db files.  You can stop reading this message because it won't apply.

===Do the following on the development machine===

If you find this new setup works on different systems as expected (this is important: with a clean fresh copy of a A2K3 db and none of the content from the suspect db), I end up doing one or two of the following two things.  The first set is easier, the second is more time consuming, but generally has been very reliable.

Create a new db with the old content:
1. Create a clean db.
2. Import all objects from the suspect db to the new db. (IMPORTANT: During this step, if it stops on any object, write that object's name down, then continue to import the rest of the objects.)
3. Open both copies of the db's in two different instances of Access in side-by-side windows.
4. Open the Startup Options and copy the settings from the suspect db to the new db.

If you had errors while importing any of the objects, this is in indication that those are the objects that are corrupted.  (Not good, because here comes the time consuming part.)

For each object that is indicated as corrupt during the first phase above (mine have always been forms or reports), those objects won't be created in the new db.  You will need to recreate them, but not necessarily from scratch.  For each:
1. Again, open both the suspect db and the new db in side-by-side Access instances.
2. In the new db, start a new version of that object (probably form or report) in the new db
3. Copy from the suspect db the UI elements of the object directly onto the new object's UI.
4. (Note: code is handled slightly differently - I learned this from a MS tech many years ago) Copy the code from the suspect db to Notepad, then select and copy the code from Notepad to the new object code module.  (If you have Access set to only show one module at a time as opposed to all modules, you can change you Options so that you can copy all code at once instead of one module at a time.)
5.  Save the new object, and repeat for any other objects that indicated corruption.

==Now compile and test your new db on the development system and other test systems.==  

This process also works wonders on reducing the size of your db after a lot of development has been done.  The db can get bloated with all the adds/edits/deletes of the access objects.  I've seen some circumstances where my db is reduced more than 50% in size just getting rid of all the junk left over from the many changes. It's obviously much easier to roll out when it is a smaller size as well.

Now, for me, in one case, after all that, there is one more circumstance that still experienced the problem you described.  If you thought the second phase was time consuming, this is worse, but it saved my bacon.  In my case, one of the forms that wouldn't import was still corrupted.  If I remember correctly, the way I figured out which one was corrupted was by treating the "new" db as suspect and imported into another clean db.  Or I just had one bad form and I used the original suspect db, either way, I narrowed down to one form that was the cause.  For this discussion, let's call it "new-new".  This "new-new" db didn't have the suspect form.  I created a new form to replace the bad one, and little by little copied over form elements, and tested along the way, until I found something that didn't work or caused a problem.  Ideally, you'd recreate this form from scratch, but often there are oodles (technical term) of elements and recreating from scratch is no fun.

Hope those ideas help you.
0
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
LVL 13

Assisted Solution

by:Chris Raisin
Chris Raisin earned 200 total points
ID: 35188568
Just one time this error occurs on a developemnt machine: This error will always happen when you open up VB6 and you ALREADY have it running. (It is probably showing in your Windows Task Manager under processes but is not visible on the desktop).

This is usuall ya result of a crash where VB6 has not closed properly.

When it happens, just check to see if it is obviously running (i.e. another instance on your desktop). If it is, simply close the current one showing the error, and open up the running instance as per normal (maximise). It will all work OK from there.

If the running instance is NOT visible on your desktop, close the current one, check in Task Manager under processes for "VB6.EXE" and if you find it, right click on it and select "End Process", then click "Yes" to accept the warning.

The problem always arises from either a nad shurdown of VB6 or and instance of VB6 already running.

I often see it when I have bugs crashing my code, and so I am aware of how it happens and the solution around it.

So on a client machine, I would assume they could paerhaps already have an instance runnig. Perhaps they clicked TWICE when starting the program, or the program runs something itslef on startup which starts another VB6 app which uses resources used by the current app. (Data/Files). Just some thoughts.....
0
 
LVL 11

Expert Comment

by:kbirecki
ID: 35192406
I run multiple instances of vb6 simultaneously all the time without problems.
0
 
LVL 2

Author Comment

by:daz84
ID: 35196352
Thank you all very much for your responses. I ended up working around the problem by convincing the client to remove 2007 and install 2010.

I will try my best to get some office time to test the above solutions in order to properly close the question so it may be of more use to others

Darren
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
The viewer will learn how to simulate a series of coin tosses with the rand() function and learn how to make these “tosses” depend on a predetermined probability. Flipping Coins in Excel: Enter =RAND() into cell A2: Recalculate the random variable…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now