Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Refresh all linked tables.? 1

Status
Not open for further replies.

Kujen

Technical User
Oct 13, 2007
57
SE
Hi all,

I have some tables in with SQL-server authentication.
I would like to refresh all linked tables after a user change his password. I have tried with;

Dim gStrConnect As String
Dim tdf As TableDefs
Dim db As Database

gStrConnect = "ODBC;DRIVER={SQL SERVER};SERVER=MyServer;Database=MyDb;UID=" & Me.strUserId & ";PWD=" & Me.strPwd

For Each tdf In db.TableDefs
If InStr(1, tdf.Connect, "MyDb") > 0 Then
With tdf
.Connect = gStrConnect
.RefreshLink
End With
End If
Next

When I run the above I get: 'Object is needed'
on row 'For Each tdf In db.TableDefs'.
I guess I need to open the database with something:
Set db = OpenDatabase(CurrentDb)

What do I have to do?

Kent J.
 
Replace this:
Dim tdf As TableDefs
with this:
Dim tdf As TableDef

And this:
For Each tdf In db.TableDefs
with this:
Set db = CurrentDb
For Each tdf In db.TableDefs

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top