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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Update TableDef .Connect Property

Status
Not open for further replies.

AtlasAF

Programmer
Feb 7, 2005
59
US
I'm trying to set the TableDef.connect property when my DB opens but it is coming through as a read only property. I have tried various methods and did a search online. All of the example I have found seem to line up with what I have coded in this module. Can anyone see a reason why I can't set the connect property in the code below?

Code:
Public Function RelinkTables(strPath As String) As Integer
Dim db As DAO.Database
Dim tdfs As DAO.TableDefs
Dim tdf As DAO.TableDef
Dim strStat As String

On Error GoTo Err:

strStat = Chr(17)
Set db = CurrentDb
Set tdfs = db.TableDefs

strPath = ";DATABASE=" & strPath

    For Each tdf In tdfs
        With tdf
                .Connect = strPath
                .RefreshLink
        End With
    Next tdf


MsgBox "Connection to: " & strPath & " Successful", vbOKOnly, "Connection Successful"

Set tdf = Nothing
Set db = Nothing

GoTo ExitFunction

Err:

MsgBox "Error Number: " & Err.Number & " Description: " & Err.Description

Set tdf = Nothing
Set rs = Nothing
Set db = Nothing

ExitFunction:

End Function

AtlasAF
 
The DB is setup in FE BE. I know I can not modify the design in the front end but shouldn't I be able to modify the connection string?

To explain further, I test the links to the table using another module and in the event that they link is broken, the user can select the backend and relink the tables by executing this function. I have done this before, however I cannot seem to get the code to work this time.

Any help would be appreciated and thanks in advance.

AtlasAF
 
I know I can not modify the design in the front end but shouldn't I be able to modify the connection string?

No. You will need Modify Design permission to change the .Connect on a table.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top