tdf.SourceTableName

F

FPS, Romney

Is it possible to use wildcards in specifying table names when refreshing
links to external databases?

I wish to link all tables beginning with "Home" (such as HomeAssessments,
HomeGoals, etc.) to one external database, and all other linked tables to
another database.

I've tried concatenating "Home" and "*", but that doesn't seem to work ...

strHomeTables1 = "Home"
strHomeTables2 = "*"
strHomeTables = strHomeTables1 & strHomeTables2

For Each tdf In Tdfs
If Len(tdf.Connect) > 0 And tdf.SourceTableName = strHomeTables Then
tdf.Connect = ";DATABASE=" & Database1
tdf.RefreshLink

ElseIf Len(tdf.Connect) > 0 And tdf.SourceTableName <> strHomeTables Then
tdf.Connect = ";DATABASE=" & Database2
tdf.RefreshLink
End If

'---------------------------------

I've also tried:

If Len(tdf.Connect) > 0 And Left(tdf.SourceTableName, 4) = "Home" Then
tdf.Connect = ";DATABASE=" & Database1
tdf.RefreshLink

Else If ...

Any help would be appreciated.
Thanks,
Mark.
 
F

FPS, Romney

This works, so I'm guessing there's something wrong somewhere else in my
procedure:

Dim dbs As Database
Dim tdf As TableDef
Dim Tdfs As TableDefs
Dim strHomeTables1 As String
Dim strHomeTables2 As String
Dim strHomeTables As String
Set dbs = CurrentDb
Set Tdfs = dbs.TableDefs

strHomeTables1 = "Home"
strHomeTables2 = "*"
strHomeTables = strHomeTables1 & strHomeTables2

For Each tdf In Tdfs
'...link main tables
If Left(tdf.SourceTableName, 4) = "Home" Then
Debug.Print tdf.SourceTableName
End If
Next
 

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