Results 1 to 4 of 4
  1. #1
    Join Date
    Nov 2003
    Location
    Europe
    Posts
    369

    Question Unanswered: can reference libraries suddenly be "disconnected"?

    Without having had any changes on my computer, is it possible that References such as DAO 3.6 can become unchecked during development of a db? ("just by themselves", or by some internal Access error that the user does not see)?

    I think I have seen how to connect/ensure that particular references are checked/enabled through VBA, can anyone provide examples for the main libraries/references?
    Nice if they are precise, as I think the reference names must be pretty exact and may contain spaces, periods etc.

    Thanks,

    D.

  2. #2
    Join Date
    Mar 2004
    Location
    www.scirocco.ca
    Posts
    346

    Re: can reference libraries suddenly be "disconnected"?

    This usually happens when you upgrade or modify a dll that has been on your list of references or control otherwise it shouldn't get unchecked by itself.

    Open the code window and go to tools and then references to check or uncheck any references.
    http://www.scirocco.ca/images/banner...occobanner.gif

    Download for FREE the ADO/DAO Data Controls that makes life EASIER developing database applications in: VB, FoxPro, Access, VC++, .NET etc... Navigate, Add New, Delete, Update, Search, Undo and Save your changes. Supports Disconnected Recordsets and Transactions!

    Or try our Ask An Expert service to answer any of your questions!

  3. #3
    Join Date
    Nov 2003
    Location
    Europe
    Posts
    369

    Re: can reference libraries suddenly be "disconnected"?

    Originally posted by SCIROCCO
    This usually happens when you upgrade or modify a dll that has been on your list of references or control otherwise it shouldn't get unchecked by itself.

    Open the code window and go to tools and then references to check or uncheck any references.
    Sure, that is where I discovered it, but my question was rather related to ensuring through code that any client computer Access installation has the desired libraries checked, when the db frontend opens. Providing the user with an error message about contacting an administrator or other if any of the required ones cannot be found/enabled.

    D.

  4. #4
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    here's my solution - i've posted this here before, but this time i've added findlibs

    it would be great to have some feedback or suggested improvements.

    izy



    first: you need to get the info for the libraries concerned: make a form with a GO button and:
    Code:
    Option Compare Database
    Option Explicit
        ''                                                                           ''
        ''  Utility: FindLibs                                                         ''
        ''                                                                           ''
    Private Sub butGo_Click()
        Dim intRef As Integer
        Dim strMsg As String
        
        If Application.References.Count = 0 Then
            MsgBox "ZERO references found. Trying to continue...", vbInformation, "No References"
        Else
            For intRef = 1 To Application.References.Count
                strMsg = strMsg & Application.References(intRef).Name & ": "
                strMsg = strMsg & Application.References(intRef).FullPath & vbCrLf
            Next
        End If
        shoBox = strMsg
    End Sub
    (maybe print or debug or msgbox instead of displaying the results in a textbox "shoBox" as i do above)

    then an automatic reference loader: make another form with the following code and set this form as the startup form. once you have set the two "programmer set" blocks using the info you got from the above form, this second form will check references on startup and set any missing ones (assuming the file is on the c: disk).
    the first run takes forever as the code searches the disk for the file (it is probably unsafe to use .FullPath since different installations may have the files in different locations, so i use only the file name info from .FullPath)
    later runs (once the references are set up) the form unloads in a fraction of a second and passes control to the form defined in Const frmOpen
    Code:
    Option Compare Database
    Option Explicit
    
    
        ''                                                                           ''
        ''  Utility: LibLoad                                                         ''
        ''                                                                           ''
        ''  Check references and if missing attempt to locate the appropriate file   ''
        ''  on drive c: and if found attempt to create the reference automatically   ''
        ''                                                                           ''
        ''    THE PROGRAMMER IS RESPONSIBLE FOR SETTING PROPERTIES IN LibLoad0()     ''
        ''                                                                           ''
    
                
                
    Private Declare Function SearchTreeForFile Lib "imagehlp" (ByVal SearchRoot As String, ByVal FileName As String, ByVal Foundfile As String) As Boolean
    
    Private Sub LibLoad0()
    
    
        ''                                                                           ''
        ''               BEGIN PROGRAMMER-SET PROPERTIES BLOCK 1 of 2                ''
        ''                                                                           ''
        ''    Declare the number of references to be checked/set as Const maxRefs    ''
        ''    Declare which form to open on successful conclusion as Const frmOpen   ''
        ''                                                                           ''
        Const maxRefs = 4
        Const frmOpen = "frmMain"
        ''                                                                           ''
        ''               END PROGRAMMER-SET PROPERTIES BLOCK 1 of 2                  ''
        ''                                                                           ''
    
        
        
        
        Dim refName(1 To maxRefs) As String
        Dim refFile(1 To maxRefs) As String
        Dim loupe As Integer
        Dim msg As String
        Dim shownAlready As Boolean
        
        
        
        
        ''                                                                           ''
        ''               BEGIN PROGRAMMER-SET PROPERTIES BLOCK 2 of 2                ''
        ''                                                                           ''
        ''    Fill arrays with name/file data using the format:                      ''
        ''         refName(1) = "DAO"             'the name of the reference         ''
        ''         refFile(1) = "dao360.dll"      'the file name.ext                 ''
        ''         refName(2)...and so on for each of maxRefs entries                ''
        ''                                                                           ''
        refName(1) = "DAO"
        refFile(1) = "dao360.dll"
        refName(2) = "Outlook"
        refFile(2) = "msoutl9.olb"
        refName(3) = "Excel"
        refFile(3) = "EXCEL9.olb"
        refName(4) = "Office"
        refFile(4) = "MSO9.DLL"
        ''                                                                           ''
        ''               END PROGRAMMER-SET PROPERTIES BLOCK 2 of 2                  ''
        ''                                                                           ''
    
        
        
        shownAlready = False
        For loupe = 1 To maxRefs
            If Not LibLoad1(refName(loupe)) Then
                If Not shownAlready Then
                    msg = "Missing library reference(s)! The system will now attempt to "
                    msg = msg & "locate the library file and automatically set a reference "
                    msg = msg & "to it. This process will take a few minutes and cause a lot of "
                    msg = msg & "disk activity. This is a one-time process and will not be necessary "
                    msg = msg & "the next time you use this application"
                    MsgBox msg, vbInformation, "Missing Reference"
                    shownAlready = True
                End If
                If Not LibLoad2(refFile(loupe)) Then
                    msg = "Could not find " & refName(loupe) & ": " & refFile(loupe)
                    msg = msg & vbCrLf & "Application will abort."
                    MsgBox msg, vbCritical, "ABORTING!"
                    DoCmd.Quit
                End If
            End If
        Next
        DoCmd.Close acForm, "utilityLibLoad"
        DoCmd.OpenForm frmOpen
    End Sub
    
    Private Function LibLoad1(NameOfRef As String) As Boolean
        Dim intRef As Integer
        If Application.References.Count = 0 Then
            MsgBox "ZERO references found. Trying to continue...", vbInformation, "No References"
        Else
            For intRef = 1 To Application.References.Count
                If Application.References(intRef).Name = NameOfRef Then
                    LibLoad1 = True
                    Exit Function
                End If
            Next
        End If
        LibLoad1 = False
    End Function
    
    Private Function LibLoad2(NameOfFile As String) As Boolean
        On Error GoTo err_LibLoad2
        Dim ref As Reference
        Dim Foundfile As String
        Foundfile = String(260, " ")
        If SearchTreeForFile("c:\", NameOfFile, Foundfile) Then
            Set ref = References.AddFromFile(Foundfile)
            LibLoad2 = True
        Else
            LibLoad2 = False
        End If
    exit_LibLoad2:
        Exit Function
    err_LibLoad2:
        MsgBox Err.Number & ": " & Err.Description, vbCritical, "Fatal error in LibLoad2"
        LibLoad2 = False
        Resume exit_LibLoad2
    End Function
    
    Private Sub Form_Load()
        LibLoad0
    End Sub
    Last edited by izyrider; 04-18-04 at 08:45.
    currently using SS 2008R2

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •