Public Function HasPriority(ByVal strRef As String) As Boolean
On Error GoTo Err_HasPriority
Dim ref As Reference
Dim strOther As String
' ensure that value passed is one of two types
If strRef <> "DAO" And strRef <> "ADODB" Then Exit Function
' depending on the type passed, assign the other
strOther = IIf(strRef = "ADODB", "DAO", "ADODB")
' look for first instance of two types in reference collection
For Each ref In References
' if reference equals specified reference
If ref.Name = strRef Then
HasPriority = True
Exit Function
' check if reference matches other type
ElseIf ref.Name = strOther Then
Exit Function
End If
Next
Exit_HasPriority:
Set ref = Nothing
Exit Function
Err_HasPriority:
Resume Exit_HasPriority
End Function
Public Function HasADO() As Boolean
On Error GoTo Err_HasADO
Dim ref As Reference
For Each ref In References
If ref.Name = "ADODB" Then
HasADO = True
Exit Function
End If
Next
Exit_HasADO:
Set ref = Nothing
Exit Function
Err_HasADO:
Resume Exit_HasADO
End Function
Public Function HasDAO() As Boolean
On Error GoTo Err_HasDAO
Dim ref As Reference
For Each ref In References
If ref.Name = "DAO" Then
HasDAO = True
Exit Function
End If
Next
Exit_HasDAO:
Set ref = Nothing
Exit Function
Err_HasDAO:
Resume Exit_HasDAO
End Function
Public Function RemoveADO() As Boolean
On Error GoTo Err_RemoveADO
Dim ref As Reference
Set ref = References("ADODB")
References.Remove ref
RemoveADO = True
Exit_RemoveADO:
Set ref = Nothing
Exit Function
Err_RemoveADO:
Resume Exit_RemoveADO
End Function
Public Function RemoveDAO() As Boolean
On Error GoTo Err_RemoveDAO
Dim ref As Reference
Set ref = References("DAO")
References.Remove ref
RemoveDAO = True
Exit_RemoveDAO:
Set ref = Nothing
Exit Function
Err_RemoveDAO:
Resume Exit_RemoveDAO
End Function
Public Function AddADO() As Boolean
On Error GoTo Err_AddADO
Dim ref As Reference
Const strADO = "C:\Program Files\Common Files\System\ADO\msado25.tlb"
Set ref = References.AddFromFile(strADO)
AddADO = True
Exit_AddADO:
Set ref = Nothing
Exit Function
Err_AddADO:
Resume Exit_AddADO
End Function
Public Function AddDAO() As Boolean
On Error GoTo Err_AddDAO
Dim ref As Reference
Const strDAO = "C:\Program Files\Common Files\Microsoft Shared\DAO\DAO350.dll"
Set ref = References.AddFromFile(strDAO)
AddDAO = True
Exit_AddDAO:
Set ref = Nothing
Exit Function
Err_AddDAO:
MsgBox Err.Description
Resume Exit_AddDAO
End Function