Thanks a million,
I actually wanted this code to use in a VBA class module, and its working great.
I used the following to get the name and GUID of the "Microsoft OLE DB Service Component 1.0 Type Library":
Code:
Sub FindGuids()
Dim ref As Access.Reference
For Each ref In Application.References
Debug.Print ref.Name & " - " & ref.Guid
Next
End Sub
This output: MSDASC - {2206CEB0-19C1-11D1-89E0-00C04FD7A829}
Then I use the name and GUID in the Class_Initialize() event of a data access class to see if MSDASC is referenced like this:
Code:
Option Compare Database
Private m_intErrorHandling As Integer
Private Const ERR_BAD_MSDASC_REFERENCE = vbObjectError + 515
'=====================================================================
' Class_Initialize
' ----------------
' Checks for a valid reference to the MSDASC library and initializes
' property default values.
'=====================================================================
Private Sub Class_Initialize()
On Error GoTo 0
Dim ref As Access.Reference
Dim blnMSDASCReferenced As Boolean, blnBroken As Boolean
Const cMSDASCGUID As String = "{2206CEB0-19C1-11D1-89E0-00C04FD7A829}"
m_intErrorHandling = Application.GetOption("Error Trapping")
Application.SetOption "Error Trapping", 2
For Each ref In Application.References
On Error Resume Next
blnBroken = ref.IsBroken
If VBA.Err Then blnBroken = True
On Error GoTo 0
If ref.Name = "MSDASC" And ref.Kind = 0 And _
VBA.StrComp(ref.Guid, cMSDASCGUID, 1) = 0 And _
Not blnBroken Then
blnMSDASCReferenced = True
Exit For
End If
Next ref
Set ref = Nothing
If Not blnMSDASCReferenced Then _
Err.Raise ERR_BAD_MSDASC_REFERENCE, "clsCursorAnalyzer::Initialize", _
"A reference to MSDASC has to be set."
End Sub
Thanks again!
Bob