Can't OpenDatabase using DAO

T

Tan SH

Hi,

I am currently using VB to create an application that uses
Access databases. The Microsoft Access version used
previously is Access 97 but I would like to update the
application for use with Access 2000.

My source code is as follow:

--------------------
Dim sFile As String
Dim dbtemp As Database

sFile = OpenDialog("Select Group Database", "Microsoft
Access (*.mdb)|*.mdb", False, False, sDPath)

If sFile <> "" Then
If Dir(sFile) <> "" Then
Set dbtemp = OpenDatabase(sFile, , True)
End If
End If
--------------------

The problem is that even though there is a value
for 'sFile' (the full dame of the Access file including
its path), the result of dbtemp is always 'nothing'.

This code works if sFile is an Access 97 file but would
not work if it is an Access 2000 file. The DAO library has
been included in the Access 2000 file.

Also, I notice that with an Access 2000 file, the DAO
library is usually not included by default. Is there a way
that I can make it available by default?

Thanks.


br/Tan
 
L

Larry Linson

I am currently using VB to
create an application that uses
Access databases. The Microsoft
Access version used previously is
Access 97 but I would like to update
the application for use with Access 2000.

Access 97 was the current version when VB6 was released. When Access 2000
(Jet 4.0 and DAO 3.6) were released, Microsoft posted a Knowledge Base
article, Q238401, explaining what you need to do to upgrade to Jet 4.0.
Search for it at http://support.microsoft.com.

However, if this is a newly created VB6 application, the fact that you did
not automatically get Jet 4.0 would indicate that you have not applied all
the Service Packs. One of them included the change for Jet 4.0... I believe
it was SP 4, and I know there have been subsequent Service Packs -- check
the Microsoft site for information. I think you'll find the Service Packs,
or information on ordering them on CD, both in the Knowledge Base and at
http://www.microsoft.com/downloads.

Many developers create a "base" or "skeleton" database with the style of
forms and controls they like, their own VBA common code in modules, startup
forms... and References. Instead of creating a new database, they just make
a copy of their "base". That will solve the problem, and maybe make life
just a little easier in other aspects of developing databases, too. I don't
know of any way to set an options so that a Reference to DAO 3.6 will
automatically be included in every new Access 2000 or 2002 database. (But,
you can be certain that Microsoft has heard complaints on this issue from
many different sources. That wasn't sufficient to get it changed between
Access 2000 and Access 2002, though. Maybe we'll have better luck with
Access 2003.)

Larry Linson
Microsoft Access MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top