Results 1 to 2 of 2
  1. #1
    Join Date
    Jan 2002

    Unanswered: Link Tables in Code


    I am trying to link a table from one Access database to another in code but am not really sure how to do it. I have tried using an ODBC connection but it says that it is not suitable. I am also getting messages telling me that ISAM drivers are not on my registry.

    Is anybody able to tell me the correct way to link tables in code.


  2. #2
    Join Date
    Jun 2002
    Mpls/St.Paul area
    Function gLinkTable(strTable As String, strPath As String) As Boolean
    ' This function creates links to a table passed.

         Dim db As Database
         Dim tdfLinked As TableDef

         On Error GoTo Error_Handler 'error handler

         Set db = CurrentDb()
         Set tdfLinked = db.CreateTableDef(strTable) 'Establish link with Table
         tdfLinked.Connect = ";DATABASE=" & strPath 'create a connection to the DCO table
         tdfLinked.SourceTableName = strTable 'specify the name of the linked Table
         db.TableDefs.Append tdfLinked 'create the link from the source to the local copy
         gLinkTable = True 'indicate successful import

         GoTo Exit_Function: 'Skip error handler

    &nbsp;&nbsp;&nbsp;&nbsp; If Err.Number <> 3033 Then
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp ; msgbox Err.Number & " : " & Err.Description
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp ; Call gErrorHandler(Err, "mdlImportDCOs:gLinkTable") 'Call the global Error handler
    &nbsp;&nbsp;&nbsp;&nbsp; Else
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp ; msgbox "User does not have permissions.", , "NO PERMISSIONS"
    &nbsp;&nbsp;&nbsp;&nbsp; End If

    &nbsp;&nbsp;&nbsp;&nbsp; gLinkTable = False 'import failed
    End Function
    Last edited by jpshay; 07-16-02 at 13:36.
    This is the day the Lord has made, I will rejoice and be glad in it.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts