Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

I need a macro to run Linked Table Manager

Posted on 2009-05-12
2
Medium Priority
?
1,653 Views
Last Modified: 2013-11-27
Hi ALL, I am trying to write a macro that will run the Linked Table Manager and use the "Select ALL" option.  In a macro,  I am able to open Linked Table Manager by using the Action "RunCommand" and the Arguments "LinkedTableManager".  But I can't seem to figure out how to make it "Select ALL" and then select the "OK" button.  Any help would be MOST aprreciated!!
0
Comment
Question by:Krista_Grubb
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 65

Accepted Solution

by:
rockiroads earned 2000 total points
ID: 24365510
I dont know of any way, because that is open as modal, you cant even use sendkeys to select "select all"

If all you want is to pick another db then why not relink via code?

eg
how to relink http://www.mvps.org/access/tables/tbl0009.htm

how to prompt http://www.mvps.org/access/api/api0001.htm
0
 
LVL 16

Expert Comment

by:Chuck Wood
ID: 24868828
If you want to relink your tables to a new or changed database, you can use the code in the snippet. Set a reference to ADOX and use the ReLinkTables procedure, substituting your database path and table names. Or, you can delete the ReLinkTables procedure and use the ReLinkTable procedure from some other code you have.
-Chuck
'===================================================
'  requires:
'    reference(s) to:
'       Microsoft ADO Ext. 6.0 for DDL and Security
'===================================================
Public Sub ReLinkTables()
On Error GoTo HandleError
    ReLinkTable "PathToDb", "TableName1"
    ReLinkTable "PathToDb", "TableName2"
    ReLinkTable "PathToDb", "TableName3"
    ReLinkTable "PathToDb", "TableName4"
ExitHere:
    Exit Sub
HandleError:
    MsgBox "Error:" & err.Number & vbNewLine & _
        err.Description & vbNewLine & _
        "In:ReLinkTables"
    Resume ExitHere
End Sub
 
Public Sub ReLinkTable(ByVal DbPath As String, _
  ByVal TableName As String)
On Error GoTo HandleError
    UnLinkTable TableName
    LinkTable DbPath, TableName
ExitHere:
    Exit Sub
HandleError:
    MsgBox "Error:" & err.Number & vbNewLine & _
        err.Description & vbNewLine & _
        "In:ReLinkTable"
    Resume ExitHere
End Sub
 
 
Public Sub UnLinkTable(ByVal TableName As String)
On Error GoTo HandleError
    Dim cat As ADOX.Catalog
    Dim tbl As ADOX.Table
    Set cat = New ADOX.Catalog
    Set tbl = New ADOX.Table
    cat.ActiveConnection = CurrentProject.Connection
    For Each tbl In cat.Tables
        If tbl.Type = "LINK" Then
            ' if this is the specified table
            If tbl.Name = TableName Then
                ' delete the specified table
                DoCmd.DeleteObject acTable, tbl.Name
            End If
        End If
    Next tbl
    ' clean up
    Set tbl = Nothing
    Set cat = Nothing
ExitHere:
    Exit Sub
HandleError:
    MsgBox "Error:" & err.Number & vbNewLine & _
        err.Description & vbNewLine & _
        "In:UnLinkTable"
    Resume ExitHere
End Sub
 
Public Sub LinkTable(ByVal DbPath As String, _
  ByVal TableName As String)
On Error GoTo HandleError
    Dim strSQL As String
    Dim tbl As ADOX.Table
    Dim intI As Integer
    Dim cat As ADOX.Catalog
    Set cat = New ADOX.Catalog
    Set tbl = New ADOX.Table
    ' if the database path does not exist,
    If Dir(DbPath) = "" Then
        ' warn the user and exit
        MsgBox "This database path does not exist:" & _
            vbNewLine & vbNewLine & DbPath, vbCritical, "Path Invalid"
        GoTo ExitHere
    End If
    cat.ActiveConnection = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
        "Data Source=" & DbPath & ";"
    ' loop through the tables,
    For Each tbl In cat.Tables
        ' if this is the table we are linking,
        If tbl.Name = TableName Then
            DoCmd.TransferDatabase acLink, "Microsoft Access", _
                DbPath, acTable, tbl.Name, tbl.Name, False
        End If
    Next tbl
    ' clean up
    Set tbl = Nothing
    Set cat = Nothing
ExitHere:
    Exit Sub
HandleError:
    Select Case err.Number
        Case 3011
            Resume Next
        Case Else
            MsgBox "Error:" & err.Number & vbNewLine & _
                err.Description & vbNewLine & _
                "In:LinkTable"
            Resume ExitHere
    End Select
End Sub

Open in new window

0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
The viewer will learn how to simulate a series of coin tosses with the rand() function and learn how to make these “tosses” depend on a predetermined probability. Flipping Coins in Excel: Enter =RAND() into cell A2: Recalculate the random variable…
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…

609 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question