| Computers Forum Index » Computer - Databases - MS Access » Weird: Priority of references changes and causes... |
|
Page 1 of 1 |
|
| Author |
Message |
| pemigh... |
Posted: Wed Nov 04, 2009 3:43 pm |
|
|
|
Guest
|
In order for my application to work, the Microsoft DAO 3.6 Object
Library needs to be third on the list of references. Can anyone tell
me why it sometimes slips further down the list, causing code to
fail? And how to prevent that?
One of my clients has now had this happen twice.
Welcoming your insights,
pemigh |
|
|
| Back to top |
|
|
|
| Banana... |
Posted: Wed Nov 04, 2009 8:54 pm |
|
|
|
Guest
|
pemigh wrote:
Quote: In order for my application to work, the Microsoft DAO 3.6 Object
Library needs to be third on the list of references. Can anyone tell
me why it sometimes slips further down the list, causing code to
fail? And how to prevent that?
One of my clients has now had this happen twice.
Welcoming your insights,
pemigh
I don't know the specific reasons but IMHO, it's always preferable to
disambiguate an explicit reference rather than depending on an implicit
priority order which can be subject to changes in different environments
or don't make a reference at all.
Disambiguation:
Dim db As DAO.Database
Dim cn As ADODB.Connection
Dim drs As DAO.Recordset
Dim ars As ADODB.Recordset
Set db = CurrentDb
Set cn = CurrentProject.Connection
Set drs = db.OpenRecordset(...)
ars.Open ...
....
drs.Close
ars.Close
Set drs = Nothing
Set ars = Nothing
Set cn = Nothing
Set db = Nothing
No reference used:
With CurrentDb.OpenRecordset(...)
...
End With
With CurrentProject.Connection.Execute(...)
...
End With
Note: Technically, ADO's Execute() method isn't as flexible as DAO's
OpenRecordset/Execute method and I don't see any benefit from not
referencing ADO objects explicitly but with DAO, it's quite possible. I
usually do both reasoning that most of time DAO is usually reliable in
referencing and use the With...End With as a means to save myself the
trouble of declaring variables. |
|
|
| Back to top |
|
|
|
| Chuck Grimsby... |
Posted: Thu Nov 05, 2009 2:15 am |
|
|
|
Guest
|
On Nov 4, 9:43 am, pemigh <pem... at (no spam) gmail.com> wrote:
Quote: In order for my application to work, the Microsoft DAO 3.6 Object
Library needs to be third on the list of references. Can anyone tell
me why it sometimes slips further down the list, causing code to
fail? And how to prevent that?
One of my clients has now had this happen twice.
Welcoming your insights,
pemigh
Third? Why third? This doesn't make any sense.... |
|
|
| Back to top |
|
|
|
|