Refresh existing link problem.

  • Thread starter Thread starter CT
  • Start date Start date
C

CT

I am trying to refresh an existing link to an external
database. However, I have the following error at
the .refreshlink statement: Error 3055 DAO.tabledef Not
a valid file name. Please point out problem. CT.


Dim db As DAO.Database
Dim tdf As DAO.TableDef

Dim i As Integer
Dim strTBLNAME As String
Set db = CurrentDb()
For i = 0 To db.TableDefs.Count - 1
strTBLNAME = db.TableDefs(i).Name
MsgBox strTBLNAME
Next
'One of the strTBLNAME values is "ALLPLT" from
for/next loop above.

'What is missing/incorrect in the following code:
'Set db = CurrentDb()
Set tdf = db.TableDefs("ALLPLT")
'strCURRENTDIRVALUE is path&name for external DB
tdf.Connect = (";DATABASE=" & strCURRENTDIRVALUE)
tdf.RefreshLink 'Error occurs at this statement
Set tdf = Nothing
Set db = Nothing
 
There are many things that could go wrong with this process, e.g.:

1. The file must be present in the path specified, i.e. you cannot link to a
file that is not there.

2. Did you include the ".mdb" in the file name?

3. Test by opening the Immediate window (ctrl+G) and entering:
? Dir(strCURRENTDIRVALUE)

There are many other issues, e.g. the file must be an Access database, in a
location with permissions in Windows, of a version that you can read,
contain the expected name of the table, and not be secured by an mdw (since
you are not providing a username/password).
 
Link currently exists and is working correctly.
Permissions ok.
External db is in same directory as front end db.
StrCURRENTDIRVALUE does bring back correct path
including .mdb
Table/Link name is the same.

But I want to re-establish link (invisible to user)if
table in back-end external db was recreated after a
delete. Or after both db moved together to new
subdirectory.

CT
 
Based on the link you provided - I switched from directly
using the name "ALLPLT" to searching thru the TableDefs
names for "ALLPLT" and using the index number to identify
the link to connect and refresh.

CT
 
Back
Top