I am having a bit of a problem with some code that is supposed to refresh links. I need to do this because I am using one back end for testing and another backend for real data. gstrDataPath and gstrDataName are variables for the backend path and name. gstrLinkTables is an array holding the table names with gintLinkTables holding the number of tables in the array.
The code is supposed to go through the list of linked tables in the array, delete each one, relink each one and then test it by opening and closing a recordset. It appears to work if there are already links in place albeit to the wrong backend but fails to relink if not.
For intI = 1 To gintLinkTables
strTable = gstrLinkTables(intI)
DoCmd.DeleteObject acTable, strTable
DoCmd.TransferDatabase acLink, “Microsoft Access”, gstrDataPath & gstrDataName, acTable, strTable, strTable
Set rs = db.OpenRecordset(strTable) ‘rs already dimmed
rs.Close
Next
Can anyone help me as to why the Transfer Database line fails to work if the preceding line didn’t have anything to delete?
David Parton