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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Re-Activating Broken Links 1

Status
Not open for further replies.

TomCarnahan

Programmer
Dec 7, 2002
123
US
Without the benefit of having the Office Developer's Edition available, I distribute an MS-Access application to users in a non-executable format (i.e. they must have MS-Access on their PC in order to run the app ...I don't have an installer).

Normally, in our small group (less than 50 users all running MS-Office 2000), it is not a problem. However, we have a LAN Administrator who is still cutting his teeth. My app refers to an number of .dll's and other libraries that are part of Access but are not normally installed. When the LAN Adminstrator reloads his baseline, sometimes he "loses" the pointers that Access has to my dll's so they are reported as MISSING (broken refs). While the refs are somewhere on the user's PC, Access can't find them and dumps the user out into the VBA Editor.

To overcome this problem, I have compiled a list of all the refs I use, their attributes such as filepaths GUIDs, major, minor, etc and have put them into a table (for purposes of illustration, call it "tblMyRefs").

What I would like to do on Startup, is have my code, enumerate the refs, determine the broken ones, look up the applicable info it needs from my table, and re-establish the links. If it cannot resolve the problem, have it display a message "Problems with dynamic link libraries ... contact the LAN Administrator!" ... just joking about the message, but I would rather have it diplay a graceful error recovery than leave the user stranded in code.

Can anyone suggest a procedure to do this?

Thank you ahead of time for your help!



--- Tom
 
Tom
this code might set you on your way.
Good luck.

The real secret though is to use as few references as possible. I normally get away with 3. VBA, Access 10.0 and DAO 3.6 (for Access 2002).

Code:
Sub FixUpRefs()
    Dim loRef As Access.Reference
    Dim intCount As Integer
    Dim intX As Integer
    Dim blnBroke As Boolean
    Dim strPath As String

    On Error Resume Next

    'Count the number of references in the database
    intCount = Access.References.Count
  
    'Loop through each reference in the database
    'and determine if the reference is broken.
    'If it is broken, remove the Reference and add it back.
    For intX = intCount To 1 Step -1
      Set loRef = Access.References(intX)
      With loRef
        blnBroke = .IsBroken
        If blnBroke = True Or Err <> 0 Then
          strPath = .FullPath
          With Access.References
            .Remove loRef
            .AddFromFile strPath
          End With
        End If
       End With
    Next
    
  Set loRef = Nothing

Tony
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top