var sidebar_align = 'right';
var content_container_margin = parseInt('290px');
var sidebar_width = parseInt('270px');
Unanswered: Link tables using code
Can anyone help? I need to link two tables from one (access) database to another (access) database using code but I don't know where to start.
Any help would be appreciated.
DoCmd. TransferDatabase acLink, "Microsoft Access", _
"C:\My Documents\NWSales.mdb", actable, "yourSourceTableName", _
That worked a treat. Thanks.
If the table is already linked it creates a duplicate link with a slightly different name. Do you know how I can check whether the table already exists first and delete it if it does? (the joys of locking down a PC so the user doesn't have mapped drive letters).
Make a function call it myTableExist like that
Function myTableExist ( TableName As String ) As Boolean Dim db As Database Dim tbl As TableDef On Error GoTo ERR_ Set db = CurrentDb Set tbl = db . TableDefs ( TableName ) myTableExist = True EXIT_ : Set db = Nothing : Set tbl = Nothing Exit Function ERR_ : myTableExist = False Resume EXIT_ End Function
Last edited by hammbakka; 11-30-06 at
If you want to refresh the link you can use:
I typically use this command with error trapping to delete and relink a table:
On Error Resume Next
DoCmd.DeleteObject acTable, strTableName
On Error Goto 0
The result is, if you have the table already setup it will delete it and refresh it. If you don't have the table setup the error trapping will continue processing and set up the link.