
VBA OpenDatabase: Access 97 <-> Access 2000
A97 uses DAO Library (where the objects you used like Database, Recordset
reside). A2K defaults to ADO Library in lieu of DAO. Beware also that both
DAO & ADO have an object by the same name "Recordset" but DAO & ADO
Recordsets are not compatible.
Open any code module, then use the Menu Tools / References ...
1. Select / check the box for DAO Library.
2. Use the Priority Up / Down Arrow and move DAO so that it has higher
Priority than ADO.
3. Better still, if you don't use ADO (if you don't know it, you don't use
it), remove / uncheck it from the References collection.
4. Fully qualify these objects to make sure that Access doesn't default to
the wrong ones. For example:
Dim Dbs As DAO.Database
Dim Rst As DAO.Recordset
Note: you don't need "DAO." with Database as ADO doesn't have Database (ADO
uses Connection) but it is a good reminder for the "DAO." for Recordset
which is more important.
HTH
Van T. Dinh
Quote:
> Hello NG,
> I want to open an MS Access database with VBA:
> Private Sub cmdStart_Click()
> Dim Dbs As Database
> Dim Rst As Recordset
> ' Open Database
> Set Dbs = OpenDatabase(App.Path & "\database1.mdb")
> Set Rst = Dbs.OpenRecordset("Table1")
> If the database is in access 97 format, everything works fine.
> Now I converted the db to access2000 and the error 'Nicht erkennbares
> Datenbankformat database1.mdb' (= database format can not be identified)
> How can I read an Access 2000 database ??
> regards
> Andreas Krause
> --
> note: remove '.nospam' from my eMail address in case of reply