[AccessD] A2003:Importing/Linking SQL Tables (and data)

Darren DICK darrend at nimblesystems.com.au
Thu Dec 15 20:10:41 CST 2005


Hi Shamil
Excellent
Got it up and working
Many many thanks

Darren 
-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Shamil
Salakhetdinov
Sent: Thursday, 15 December 2005 2:22 AM
To: Access Developers discussion and problem solving
Subject: Re: [AccessD] A2003:Importing/Linking SQL Tables (and data)

Darren,

This code works well here:

Public Sub Import()
Dim strCnn As String
    strCnn = "ODBC;DRIVER=SQL Server;" & _
             "SERVER={1};" & _
             "DATABASE={2};" & _
             "Trusted_Connection=Yes;"
    strCnn = Replace(strCnn, "{1}", "(local)") ' server
    strCnn = Replace(strCnn, "{2}", "pubs")    ' database

    DoCmd.TransferDatabase _
          acImport, _
          "ODBC", _
          strCnn, _
          acTable, _
          "authors", _
          "authors"
End Sub

Public Sub Link()
Dim strCnn As String
    strCnn = "ODBC;DRIVER=SQL Server;" & _
             "SERVER={1};" & _
             "DATABASE={2};" & _
             "Trusted_Connection=Yes;"
    strCnn = Replace(strCnn, "{1}", "(local)") ' server
    strCnn = Replace(strCnn, "{2}", "pubs")    ' database

    DoCmd.TransferDatabase _
          acLink, _
          "ODBC", _
          strCnn, _
          acTable, _
          "authors", _
          "linked_authors"
End Sub

Hope it will work for you too.

Shamil




More information about the AccessD mailing list