Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

method '~' of object '~' failed

Posted on 2011-03-21
6
Medium Priority
?
536 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 120

Expert Comment

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

http://www.connectionstrings.com/access-2007
0
 
LVL 85
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 1200 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 13

Assisted Solution

by:Chris Raisin
Chris Raisin earned 800 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

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article helps those who get the 0xc004d307 error when trying to rearm (reset the license) Office 2013 in a Virtual Desktop Infrastructure (VDI) and/or those trying to prep the master image for Microsoft Key Management (KMS) activation. (i.e.- C…
If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
The viewer will learn how to  create a slide that will launch other presentations in Microsoft PowerPoint. In the finished slide, each item launches a new PowerPoint presentation and when each is finished it automatically comes back to this slide: …
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
Suggested Courses

604 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