Fixing a missing reference automatically?

bionicman

Registered User.
Local time
Yesterday, 22:26
Joined
Jul 22, 2003
Messages
145
Hello Everyone!

Forgive me if this has been addressed, but i couldn't seem to locate what i was looking for when i searched.

I am developing a database that has various e-mail functions, and the reference is causing problems whenever i push out an update to my users as i have a newer version of office than they do. I have outlook 11 and they all have outlook 10

So my goal was to have some code on a splash screen that would check their version of office and corect the references if necessary.

I found this code which would remove a reference
Code:
strname = "Outlook"
Set ref = Access.References(strname)
Access.References.Remove ref
Set ref = Nothing

This works great on my machine, it removes the reference. However, when i run this on the users machine it gives me an error loading the dll. I have a feeling that this is because the reference is already missing, so it can't remove something it doesn't know it has.

I can't add the reference required because it has the same name as the missing one, so i need to be able to uncheck the missing reference via code before i can check the correct one.

I found another thread that was a link to a knowledgebase article, but it got me no where.

Does anyone know a way to do this?

Thank You,
 
Just a followup, i was never able to find a solution to this problem, but i came up with a work around... probably not the prettiest, but it works, and after a day and a half of looking for a solution thats all that matters to me.

Essentially when i load my splash screen i do a check of windows and office versions so the database knows where to look for the references, then i load all the references that are needed.

Then when i close my form i uncheck all of them.

Again probably not the neatest, but it works. If anyone needs (or wants :) ) more details about this, i can provide them.
 
bionicman, can you please share what you did exactly.

thanks
 
You can try the method boblarson posted, but i didn't have any luck with it, which is why i came up with this way.

I have a splash form that i show on startup that will load any references that are needed.

Here is the code i use to load references... Just check in your database that you are developing on to get the needed information. Outlook was the reference that was giving me problems, so i will use it as an example.

Code:
    strFile = "C:\Program Files\Microsoft Office\Office10\MSOUTL.OLB"
    Set ref = References.AddFromFile(strFile)

Be sure you check which version of windows and office the users computer is using as that could put the reference's in different locations. You can find some code on this forum to help you here.


Then whenever I close my main form, I loop through all the references and uncheck them all, that way when the database opens again, it is ready to check the needed ones using the code above. Here is the code to uncheck the references.

Code:
  Dim ref As Reference, strFile As String
  On Error Resume Next
 
    Err.Clear

    'Count the number of references in the database
    intCount = Access.References.Count
    
    For intX = intCount To 1 Step -1
      Set loRef = Access.References(intX)
      Debug.Print loRef.Name, loRef.FullPath
        
      With loRef
            
        Err.Clear
        strPath = .FullPath
        With Access.References
          .Remove loRef
        End With
      End With
    Next
    
    Set loRef = Nothing

I would put some precautions in place to be sure the user closes the database how YOU want them to, that way this code to uncheck references will run.

Just as a note, i didn't write any of this code, I just found it... but thanks goes to whoever did.

Hope this helps!
 

Users who are viewing this thread

Back
Top Bottom