M
Max Moor
Hi All,
I was pointed to some code for linking to my backend using ADOX
code (thanks, Doug). I was also pointed to code using the Windows API
to open the file box. That part works fine, and returns the path to the
backend correctly. With a few edits, the ADOX code is below...
Public Sub RefreshTableLinks()
Dim cn As New ADODB.Connection
Dim cat As New ADOX.Catalog
Dim tbl As New ADOX.Table
Dim strBackend As String
strBackend = GetFileName
-> cn.Open CurrentProject.Connection
' Open the catalog.
cat.ActiveConnection = cn
For Each tbl In cat.Tables
tbl.Properties("Jet OLEDB:Link Datasource") = strBackend
Next
cn.Close
End Sub
When I call cn.Open, I get the message:
"The database has been placed in a state by user 'Admin' on machine
'MAX' that prevents it from being opened or locked."
Can anyone give me a clue what I need to do differently? I
changed the original connection string to just use the current project
connection. Is that valid?
- Max
I was pointed to some code for linking to my backend using ADOX
code (thanks, Doug). I was also pointed to code using the Windows API
to open the file box. That part works fine, and returns the path to the
backend correctly. With a few edits, the ADOX code is below...
Public Sub RefreshTableLinks()
Dim cn As New ADODB.Connection
Dim cat As New ADOX.Catalog
Dim tbl As New ADOX.Table
Dim strBackend As String
strBackend = GetFileName
-> cn.Open CurrentProject.Connection
' Open the catalog.
cat.ActiveConnection = cn
For Each tbl In cat.Tables
tbl.Properties("Jet OLEDB:Link Datasource") = strBackend
Next
cn.Close
End Sub
When I call cn.Open, I get the message:
"The database has been placed in a state by user 'Admin' on machine
'MAX' that prevents it from being opened or locked."
Can anyone give me a clue what I need to do differently? I
changed the original connection string to just use the current project
connection. Is that valid?
- Max