Reference to old DAO keeps breaking (1 Viewer)

alikona

Registered User.
Local time
Today, 05:28
Joined
Dec 27, 2019
Messages
21
Hi all,

I have this really old database that was most likely created in Access '97. A colleague got it working when we upgraded to 2016 and part of that was manually installing Microsoft DAO 2.5/3.5 Compatability Library. The issue is, every time this database is opened, the reference seems to disappear from the loaded References list (it doesn't even show as MISSING) and then the database gives off errors and does not work.

This database is located on our network and is used by several people (not at the same time). I'm not sure if that has something to do with the reference being removed or not.

The section that is flagged when the error occurs is the following:

Code:
Dim SourMyDB As Database
Dim SourMyData As Recordset

I've been fiddling with a copy of the database after doing a google search on the issue. One post I found said you could just change 'Dim as Database' to 'Dim as Object'. Can you do the same thing for 'Dim as Recordset'?

I did try changing both 'Database' and 'Recordset' to 'Object" and the database now compiles and seems to work correctly. I'm not really sure if this is a good idea or not. Could someone provide some feedback/suggestions?
 

Isaac

Lifelong Learner
Local time
Today, 03:28
Joined
Mar 14, 2017
Messages
8,738
Does the situation improve if you change the type to be a proper, full reference?

as dao.database

not:
as database
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 05:28
Joined
Feb 28, 2001
Messages
27,001
The problem with using old databases is that they need old libraries. If you have other databases that are also Access-based but for newer versions of Access, there can be a registry interaction. At least some of your reference information is stored in the HKCU (current user) hive of the registry. If you used that old reference, then used a newer version of Access with a newer library, there is a CHANCE (not a certainty) that the newer version of Access will try to update the registry for you to the newer libraries.

It IS possible to declare something an object (essentially, a faceless object). The Access run-time code has to then decide what kind of object you meant when the app starts up. There is, however, still the problem that if a different Access app messes with your settings, you will still have the headaches.

There IS a way to force a reference to a specific path/file. See this reference and look at the non-GUID option that is described in the solution.

 

silentwolf

Active member
Local time
Today, 03:28
Joined
Jun 12, 2009
Messages
545
Hi,
I guess it is easier for you to look up late and early binding to get more information about that.
Pretty sure there is alot of infos out there to read up on.
And there is nothing wrong by late binding which is the case when using object.
Downside of using late binding is that you are not able to use intellisence.


HTH
 

alikona

Registered User.
Local time
Today, 05:28
Joined
Dec 27, 2019
Messages
21
Does the situation improve if you change the type to be a proper, full reference?

as dao.database

not:
as database
No such luck with this.

Thanks for the input all, I have some more reading to do!
 

isladogs

MVP / VIP
Local time
Today, 10:28
Joined
Jan 14, 2017
Messages
18,186
The old DAO reference libraries have long since been superceded. Replace this with the current equivalent: Microsoft Office xx.0 Access Database Engine Object library where xx.0 is a number depending on the Access version e.g. 16.0 for A2016/2019/365

Recommend you define the variables explicitly:
Code:
Dim SourMyDB As DAO.Database
Dim SourMyData As DAO.Recordset
 

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 10:28
Joined
Sep 12, 2006
Messages
15,614
I doubt you need that compatibility library in A2016.

You might have an issue if the ADO library is showing above the DAO library in your references, as then Access will try to use ADO for all the DAO commands, and some will fail.

this is all I have as standard

libraries.png
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 06:28
Joined
Feb 19, 2002
Messages
42,981
I have a lot of databases that started life in older versions and have no trouble upgrading the DAO libraries. The most important thing is to disambiguate ALL DAO objects.

DAO.Database
DAO.Recordset
DAO.Querydef
DAO.Tabledef

Once you do that, you should not need ANY reference to DAO library since Access has one built in.
 

Users who are viewing this thread

Top Bottom