Hello,
Trying to finally learn DSNless connections...
This works fine, to connect me to a single named table:
...but when i wanted to loop through the various linked tables, connecting all of them, and try the below:
I get a "Compile error: Type Mismatch" on the open form event where this is being run from...
Can someone push me in the right direction? I thought this would work...?
Thanks!
-Matt G.
Trying to finally learn DSNless connections...

This works fine, to connect me to a single named table:
Code:
'####### DSNless Connection #######
Dim sConnect As String
sConnect = "ODBC;DRIVER={sql server};DATABASE=PrioPlansDB3;SERVER=Alex;Trusted_Connection=Yes;"
Dim tdf As DAO.TableDef
Dim db As DAO.Database
Set db = CurrentDb
Set tdf = db.TableDefs("dbo_AppUsers")
tdf.Connect = sConnect
tdf.RefreshLink
Set tdf = Nothing
Set db = Nothing
Code:
'####### DSNless Connection #######
Dim sConnect As String
sConnect = "ODBC;DRIVER={sql server};DATABASE=PrioPlansDB3;SERVER=Alex;Trusted_Connection=Yes;"
Dim tdf As DAO.TableDef
Dim db As DAO.Database
Set db = CurrentDb
For Each tdf In db.TableDefs
' ignore system and temp tables
If Not (tdf.Name Like "msys" Or tdf.Name Like "~*") Then
Set tdf = tdf.Name
tdf.Connect = sConnect
tdf.RefreshLink
End If
Next
Can someone push me in the right direction? I thought this would work...?
Thanks!
-Matt G.