Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Reference Library

Status
Not open for further replies.

Eightball3

Programmer
Nov 23, 2002
138
US
Can you set a reference library using code? I have a front end database that will now use the Microsoft Outlook 9.0 Object Library but each of the computers it is used on doesn't have that refernce library set. During the OnOpen of my main form is there a way to set that reference if it is not set? Thanks.
 
Try this - it's straight from the MSAccess help files.

The following example creates a reference to a specified type library:

Function ReferenceFromFile(strFileName As String) As Boolean
Dim ref As Reference

On Error GoTo Error_ReferenceFromFile
Set ref = References.AddFromFile(strFileName)
ReferenceFromFile = True

Exit_ReferenceFromFile:
Exit Function

Error_ReferenceFromFile:
MsgBox Err & ": " & Err.Description
ReferenceFromFile = False
Resume Exit_ReferenceFromFile
End Function

You could call this function by using a procedure such as the following, which creates a reference to the calendar control:

Sub CreateCalendarReference()
If ReferenceFromFile("C:\Windows\System\Mscal.ocx") = True Then
MsgBox "Reference set successfully."
Else
MsgBox "Reference not set successfully."
End If
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top