Late binding to an object through and MDE file

I have an Access database that uses two objects by third parties.  The “main form” for the database is where both objects reside and they have references set for both of them (pointing to an .ocx file), via VBA, References.  At present the location of the .ocx files is  "C:\Program Files\CompanyName\AppName\Third Party Drivers", but there is a chance that this may need to be changed in the near future perhaps "C:\Program data\..." or "E:\Something\...".

I know that I could open up the master databases for each installation, but I really want to avoid having more then one master database to manage.

I am speaking with the software companies, but I need to explore all options.  If I could somehow set the ocx locations for these controls with the main form is loaded (even in an MDE file), that would be the best solution for me.

Don't know if there is any way, but any help would be appreciated as always.
Andy BrownDeveloperAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

YohanFCommented:
See below, the "OCX Name" shuld be the name as of the list, not the file name. As in when you load the file MS Access sometimes recognise it with a different name...

Adcthe full path name where it says "OCX path name" e.g.- "E:\Something\aaa.ocx"


To find it out what I did was, loop though this and used a msgbox to output all references, and add the correct name in their.

hope this helps
Private Sub addReferences()
    Dim refCurr As Reference
    Dim FoundIt As Boolean
    Dim str As String
    On Error Resume Next

    'Add OCX
    FoundIt = False
    For Each refCurr In Application.References
        If refCurr.Name = "OCX Name" Then
            FoundIt = True
            Exit For
        End If
    Next
    
    str ="OCX path name"
    Call Shell("Regsvr32.exe /s " & str)
    
    If FoundIt = False Then
        Application.References.AddFromFile (str)
    End If
End Sub

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Andy BrownDeveloperAuthor Commented:
Ahhhhh - interesting, so that should work with an MDE file?
0
YohanFCommented:
yep, it does.. thats what I did and makes the life very eacy. What I also did what when I am distributing files I copied all the ocx and reference files in to a folder in the same place as MDE and make sure I refresh teh references every time user load teh software.

i.e.- str = CurrentProject.Path & "\references\test.ocx"

and teh good point is, this will only refresh reference if it is missing...
0
Andy BrownDeveloperAuthor Commented:
As sad as it sounds - that's the best news i've had all day.


Thank you - very much appreciated.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.