Linked Table value

H

hmlim

Hi, all
anybody know how to get a linked table path value using VBA code?
I have a table is a linked table, inside my VBA code, I need to know
where the external source for linked table, can anybody help?


hmlim
 
C

Cameron Sutherland

Here is some DAO code that will do waht you need:

Dim db As Database
Dim varTable As Variant
Dim strTableName As String
Dim strFileAndPath As String
Set db = CurrentDb
For Each varTable In db.TableDefs
If Len(varTable.Connect) > 1 Then 'its a linked table
strTableName = varTable.Name
'linked tables start with ";DATABASE="
'so we need to strip that away
strFileAndPath = Mid(varTable.Connect, 11, Len
(varTable.Connect) - 10)
End If
Next
Set db = Nothing

-Cameron Sutherland
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top