You can....but it has to be the very first routine that runs during start up
and any code it the module must have explicit declarations (see
http://www.trigeminal.com/usenet/usenet026.asp?1033 for additional info).
Example code follows:
Sub CheckReferences()
Dim ref As Access.Reference
Dim intResponse As Integer
Dim blnMissing As Boolean
Dim strURL As String
Dim strBAD As String
Dim strMSG As String
On Error Resume Next
For Each ref In Access.Application.References
If ref.IsBroken Then
strBAD = vbCrLf & vbTab & ref.FullPath & " "
blnMissing = True
End If
Next
If DAO_OK() = False Then
VBA.MsgBox "One or more DAO files is missing, corrupt, or not
registered." _
& vbCrLf & vbCrLf & "This error may result from an
incomplete or failed installation of Microsoft Access and/or its components
and will prevent the software from functioning properly." _
& vbCrLf & vbCrLf & "Please see articles 296205, 319841, or
319844 in Microsoft's Knowledge Base at support.microsoft.com.", _
vbApplicationModal + vbCritical + vbOKOnly, _
"DAO Reference Error"
Access.Application.DoCmd.Quit
End If
If blnMissing Then
strMSG = "The following referenced files are missing or corrupt and
will prevent the software from functioning properly:" _
& vbCrLf & strBAD
Access.Application.DoCmd.Quit
Else
'Refs OK...safe to run other code
Access.Application.Run "NextStartUpRoutine"
End If
End Sub
Function DAO_OK() As Boolean
Dim varDBE As Variant
On Error Resume Next
If Access.Application.SysCmd(acSysCmdAccessVer) = "8.0" Then
Set varDBE = VBA.CreateObject("DAO.DBEngine.35")
Else
Set varDBE = VBA.CreateObject("DAO.DBEngine.36")
End If
DAO_OK = (Err.Number = 0)
End Function