Access Forms - Changing Shared Link Data Source


I wish to distribute my access forms to customers who do not have MS Access, i.e. they will execute them via the run time library.

My forms contain links to SQL Server DB tables only. These links need to be changed per customer during configuration/installation. The table names will be the same, but the host name, DB user, DB name may not.

Please tell me this is possible! I can't find out how to it. Do I need to create a form to handle it?


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.

You just need a button to open the linked tables manager..

Private Sub Command0_Click()
DoCmd.RunCommand acCmdLinkedTableManager
End Sub
mullykidAuthor Commented:
Thanks Peter.

When I run it inside access it works.

When I run it via the run time library though it crashes. Do you know why? This is where I need it to work.

mullykidAuthor Commented:

It appears this is not a run time feature, and other code is required.
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

Didn't realise this was regarded as a 'design' feature.

It's a lot of code then.
Here is a standard approach.

mullykidAuthor Commented:

This appears to be for Oracle ODBC. Anything for SQL Server?
mullykidAuthor Commented:

I think I may do this. Create a form so that the DBName, Server, user name and password etc. can be configured/entered by the user  (at install time for example) and then store this data and update the connection string for each Link table.

Can you show me how I would update the connection string with such variables?
I just answered something very similar.
Have a look and post if you wind up in the weeds.

TEST with the run-time.
The run-time is designed to be unhappy with design changes.
What works full blown may not work run-time, so TEST in that environment
mullykidAuthor Commented:
Hey Nick. Thanks for your reply.

The link doesn't seem to work. It loads a blank page. Can you give me your suggestion?
It loads good on my units.
Try this link here
Here is the original code

Function Refresh_Table_Link()
On Error GoTo myerr
Dim TD As TableDef
Dim linkstring As String
Dim intSubStringLoc As Integer
For Each TD In CurrentDb.TableDefs
    If Len(TD.Connect) > 0 Then
        intSubStringLoc = InStr(TD.Connect, "WhateverBadNameYouHaveOnTheGo")
        If intSubStringLoc > 0 Then
                linkstring = SomeCodeThatIsYourNewConnectionString
                If TD.Connect <> linkstring Then
                    TD.Connect = linkstring
                End If
        End If
    End If

Exit Function
MsgBox TD.Name
Resume Next

End Function

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
mullykidAuthor Commented:
Dude, thanks a million. Finally a sensible way of doing this.
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.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.