ADO Relink SQL table code problem in Access 2007

J

JP Dev

Hi,

I am having a problem with the following code in Access 2007 ACCDB file with
relinking tables. Error is Run-time error -2147467259 (80004005) Could not
find field. I get to the replace part where it fails. The same code works in
MDB file ok. References are ok and code is as follows:

Dim catDB As New ADOX.Catalog
Dim tblList As New ADOX.Table
DoCmd.SetWarnings False
catDB.ActiveConnection = CurrentProject.Connection

For Each tblList In catDB.Tables
If tblList.Type = "PASS-THROUGH" Then
If Me.DatabaseChooseField = "Development" Then
If InStr(tblList.Properties("Jet OLEDB:Link Provider String"),
"DATABASE=Production") > 0 Then
tblList.Properties("Jet OLEDB:Link Provider String") = Replace
(tblList.Properties("Jet OLEDB:Link Provider String"), "DATABASE=Production",
"DATABASE=Development")
End If
End If

If Me.DatabaseChooseField = "Production" Then
If InStr(tblList.Properties("Jet OLEDB:Link Provider String"),
"DATABASE=Development") > 0 Then
tblList.Properties("Jet OLEDB:Link Provider String") = Replace
(tblList.Properties("Jet OLEDB:Link Provider String"), "DATABASE=Development",
"DATABASE=Production")
End If
End If
End If
Next

catDB.Tables.Refresh
Set catDB = Nothing

PS: The back end is a SQL Server with two database, Development and
Production

Any help appreciated
Thanks,
James
 

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