Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7842775
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T16:24:03+00:00 2026-06-02T16:24:03+00:00

I’ve got a mission-critical Access 2003 database that changed from a local MDB, to

  • 0

I’ve got a mission-critical Access 2003 database that changed from a local MDB, to an MDB frontend with the backend on MS SQL Server 2005, using the Microsoft SQL Server Database Migration Assistant (SSMA) software.

Now, I need to permanently change the server that the tables are linked to from an IP address (which is changing soon) to a hostname pointing to the same server. The server itself is not changing, just the connection string.

It’s a DSN-less connection, so the ODBC info is contained within the Access MDB file. If I try to refresh the table links within Access, it prompts me for a DSN (which I don’t want to use).

I’ve done some Googling, and I’ve found several scraps of code to have it update itself each time the program launches. But, I’m worried that that could potentially introduce problems or delays for the users. Is that my best option, or is there some trick to permanently change the connection string stored within the MDB?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T16:24:04+00:00Added an answer on June 2, 2026 at 4:24 pm

    The following code has served me well for years:

    Function LinkTable(DbName As String, SrcTblName As String, _
                       Optional TblName As String = "", _
                       Optional ServerName As String = DEFAULT_SERVER_NAME, _
                       Optional DbFormat As String = "ODBC") As Boolean
    Dim db As dao.Database
    Dim TName As String, td As TableDef
    
        On Error GoTo Err_LinkTable
    
        If Len(TblName) = 0 Then
            TName = SrcTblName
        Else
            TName = TblName
        End If
    
        'Do not overwrite local tables.'
        If DCount("*", "msysObjects", "Type=1 AND Name=" & Qt(TName)) > 0 Then
            MsgBox "There is already a local table named " & TName
            Exit Function
        End If
    
        Set db = CurrentDb
        'Drop any linked tables with this name'
        If DCount("*", "msysObjects", "Type In (4,6,8) AND Name=" & Qt(TName)) > 0 Then
            db.TableDefs.Delete TName
        End If
    
        With db
            Set td = .CreateTableDef(TName)
            td.Connect = BuildConnectString(DbFormat, ServerName, DbName)
            td.SourceTableName = SrcTblName
            .TableDefs.Append td
            .TableDefs.Refresh
            LinkTable = True
        End With
    
    Exit_LinkTable:
        Exit Function
    Err_LinkTable:
        'Replace following line with call to error logging function'
        MsgBox Err.Description
        Resume Exit_LinkTable
    End Function
    
    
    
    Private Function BuildConnectString(DbFormat As String, _
                                        ServerName As String, _
                                        DbName As String, _
                                        Optional SQLServerLogin As String = "", _
                                        Optional SQLServerPassword As String = "") As String
        Select Case DbFormat
        Case "NativeClient10"
            BuildConnectString = "ODBC;" & _
                                 "Driver={SQL Server Native Client 10.0};" & _
                                 "Server=" & ServerName & ";" & _
                                 "Database=" & DbName & ";"
            If Len(SQLServerLogin) > 0 Then
                BuildConnectString = BuildConnectString & _
                                     "Uid=" & SQLServerLogin & ";" & _
                                     "Pwd=" & SQLServerPassword & ";"
            Else
                BuildConnectString = BuildConnectString & _
                                     "Trusted_Connection=Yes;"
            End If
    
        Case "ADO"
            If Len(ServerName) = 0 Then
                BuildConnectString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
                                     "Data Source=" & DbName & ";"
            Else
                BuildConnectString = "Provider=sqloledb;" & _
                                     "Server=" & ServerName & ";" & _
                                     "Database=" & DbName & ";"
                If Len(SQLServerLogin) > 0 Then
                    BuildConnectString = BuildConnectString & _
                                         "UserID=" & SQLServerLogin & ";" & _
                                         "Password=" & SQLServerPassword & ";"
                Else
                    BuildConnectString = BuildConnectString & _
                                         "Integrated Security=SSPI;"
                End If
            End If
        Case "ODBC"
            BuildConnectString = "ODBC;" & _
                                 "Driver={SQL Server};" & _
                                 "Server=" & ServerName & ";" & _
                                 "Database=" & DbName & ";"
            If Len(SQLServerLogin) > 0 Then
                BuildConnectString = BuildConnectString & _
                                     "Uid=" & SQLServerLogin & ";" & _
                                     "Pwd=" & SQLServerPassword & ";"
            Else
                BuildConnectString = BuildConnectString & _
                                     "Trusted_Connection=Yes;"
            End If
        Case "MDB"
            BuildConnectString = ";Database=" & DbName
        End Select
    End Function
    
    
    Function Qt(Text As Variant) As String
    Const QtMark As String = """"
        If IsNull(Text) Or IsEmpty(Text) Then
            Qt = "Null"
        Else
            Qt = QtMark & Replace(Text, QtMark, """""") & QtMark
        End If
    End Function
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got a string that has curly quotes in it. I'd like to replace
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have a French site that I want to parse, but am running into
I am doing a simple coin flipping experiment for class that involves flipping a
I have a text area in my form which accepts all possible characters from
i got an object with contents of html markup in it, for example: string

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.