MikeAngelastro
Registered User.
- Local time
- Today, 16:08
- Joined
- Mar 3, 2000
- Messages
- 254
Hi,
I'm maintaining a frontend access db that can be attached to different backends depending on what company it is for. Each company frontend has tables that are linked to the same backend because they are common to all companies and other tables that are linked to their own backend. The tables that are linked to their own backend are specified in a table called "tblMyLinkedTables" containing the connect string of the of their specialized backend. This table is in the common backend db. I want to be able to change the connect string to the appropriate one for any particular company based on this table. I am using the following code the make the change, but the change does not actually occur. No error is raised either. It's as if the properties of tabledefs are read-only.
Public Function CorrectMyLinkedTables()
'Purpose: To update the table links of the db's linked tables so that they agree with tblMyLinkedTables.
Dim td As TableDef
Dim MyLinkedTables As DAO.Recordset
Set MyLinkedTables = CurrentDb.OpenRecordset("qryMyLinkedTables", dbOpenSnapshot)
With MyLinkedTables
.MoveFirst
Do Until .EOF
If Len(CurrentDb.TableDefs(!Name).Connect) > 0 Then
CurrentDb.TableDefs(!Name).Connect = !ConnectString
CurrentDb.TableDefs(!Name).RefreshLink
End If
.MoveNext
Loop
End With
End Function
Does anyone know why the above code does not work?
Thanks,
Mike
I'm maintaining a frontend access db that can be attached to different backends depending on what company it is for. Each company frontend has tables that are linked to the same backend because they are common to all companies and other tables that are linked to their own backend. The tables that are linked to their own backend are specified in a table called "tblMyLinkedTables" containing the connect string of the of their specialized backend. This table is in the common backend db. I want to be able to change the connect string to the appropriate one for any particular company based on this table. I am using the following code the make the change, but the change does not actually occur. No error is raised either. It's as if the properties of tabledefs are read-only.
Public Function CorrectMyLinkedTables()
'Purpose: To update the table links of the db's linked tables so that they agree with tblMyLinkedTables.
Dim td As TableDef
Dim MyLinkedTables As DAO.Recordset
Set MyLinkedTables = CurrentDb.OpenRecordset("qryMyLinkedTables", dbOpenSnapshot)
With MyLinkedTables
.MoveFirst
Do Until .EOF
If Len(CurrentDb.TableDefs(!Name).Connect) > 0 Then
CurrentDb.TableDefs(!Name).Connect = !ConnectString
CurrentDb.TableDefs(!Name).RefreshLink
End If
.MoveNext
Loop
End With
End Function
Does anyone know why the above code does not work?
Thanks,
Mike
Last edited: