Solved

DBEngine object not found in Excel

Posted on 1998-11-04
12
724 Views
Last Modified: 2013-12-25
Hi,

I'm writing a little VB module that is to export data from
Excel 7.0 to an Access 7.0 Database file. I try to create a
Database Object using DBEngine.OpenConnection,
however I always get run-time error 424 - "Object
Required". Any ideas why the DBEngine object cannot
be found?

Thanx
0
Comment
Question by:bogie2
[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
  • 3
  • 3
  • 2
  • +3
12 Comments
 

Author Comment

by:bogie2
ID: 1497434
Edited text of question
0
 
LVL 2

Expert Comment

by:Poddy
ID: 1497435
you need to add the DAO to your references
0
 

Author Comment

by:bogie2
ID: 1497436
I DO have a reference to the DAO library! And it still does not find the
object DBEngine. Very strange. Could it be registry-entry missing?

0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Expert Comment

by:csalves
ID: 1497437
Hello,

You have to check if your Excel apps is correctly registered.

If it is you have to create an variable of object type and start your object as an excel apps. What i wont to mean is:
Use the CreateObject Function or GetObject if you're already running your excel apps.

regards,

0
 
LVL 1

Expert Comment

by:csalves
ID: 1497438
I'm sorry bogie2...
0
 
LVL 13

Expert Comment

by:Mirkwood
ID: 1497439
Try this and see if it works ok
    Dim dbe As New DBEngine
    dbe.OpenConnection "apekool.mdb"

0
 
LVL 5

Expert Comment

by:vboukhar
ID: 1497440
Maybe must be something like that:
    Dim wrkJet As Workspace
    Dim dbsMy As Database
    Set wrkJet = DBEngine.CreateWorkspace("special", "admin", "")
    Set dbsMy = wrkJet.OpenDatabase("d:\dict.mdb")
in ObjectBrowser I not found OpenConnection for DBEngine at all.
0
 
LVL 3

Expert Comment

by:fguerreiro_inix
ID: 1497441
Hello Bogie2

At first, if you want to create an Access 7.0 Database, you must use DBEngine.CreateDatabase to create an MDB file. If you use OpenConnection it only is going to work with ODBC Databases(Opens a Connection object on an ODBC data source - ODBCDirect workspaces only).

Look at this:

This example uses CreateDatabase to create a new, encrypted Database object.

Sub CreateDatabaseX()

   Dim wrkDefault As Workspace
   Dim dbsNew As DATABASE
   Dim prpLoop As Property

   ' Get default Workspace.
   Set wrkDefault = DBEngine.Workspaces(0)
   
' Make sure there isn't already a file with the name of
' the new database.

  If Dir("NewDB.mdb") <> "" Then Kill "NewDB.mdb"
     ' Create a new database
     Set dbsNew = wrkDefault.CreateDatabase("NewDB.mdb", _
            dbLangGeneral, dbEncrypt)
  endif
End Sub

You don't need to instatiate DBEngine.
DBEngine has a default workspace alredy created DBEngine.Workspaces(0).

Hope this helps
Regards

0
 

Author Comment

by:bogie2
ID: 1497442
Thanks for all your comments. However, I still face the same old problem.
Any reference to the DBEngine object (which should exist by default) is
flagged "Error 424 - Object required". The scripts used to work fine before,
by they stopped working when I reinstalled Windows. What could it be?
I also tried reinstalling Excel, but it does not help, unfortunately.
Any ideas?
0
 
LVL 5

Expert Comment

by:vboukhar
ID: 1497443
What about my comment?
0
 
LVL 3

Expert Comment

by:fguerreiro_inix
ID: 1497444
What's DAO version are you using?
0
 
LVL 3

Accepted Solution

by:
fguerreiro_inix earned 600 total points
ID: 1497445
Your registry must be a great confusion.

You have a problem in the registry with DAO.


Run RegClean, Unistall Access, Run RegClean, Install Access,Run RegClean again.
See it work

Regards
0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

717 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