problem with RefreshLink function (1 Viewer)

carpeneda

Carpeneda
Local time
Today, 07:55
Joined
Mar 5, 2009
Messages
9
Hello all,

I'm trying to redirect the tables in my backend file to another path by using the .connect property and .RefreshLink method.
When executing .RefreshLink , error #3031 (no valid argument) occures, but I don't find any wrong expression in my code.
This is my code:
Dim objTb As DAO.TableDef
Dim objDb As DAO.Database
Set objDb = CurrentDb
For Each objTb In objDb.TableDefs
sConnect = ";DATABASE=D:\Mydata.accdb"
objTb.Connect = sConnect
objTb.RefreshLink
Next
.
.
Any idea what my be wrong with the expression for sConnect?:confused:
Thank you for any help!
 

namliam

The Mailman - AWF VIP
Local time
Today, 08:55
Joined
Aug 11, 2003
Messages
11,695
I am unsure as to 2010 perhaps using different connect ways....

Only thing I can think of is your trying to connect a local/sys table?
Perhaps you should make sure your working with a linked table by using something like:
Code:
If tbl.Attributes = dbAttachedTable Then
... relink etc..
End if
 

carpeneda

Carpeneda
Local time
Today, 07:55
Joined
Mar 5, 2009
Messages
9
I have split the access file to front-end and back-end.
My tables (back-end) are linked to a file called "MyData.accdb".
The directory for this file to be stored has to be flexible.
The new location is defined by the .connect property. But this seems not to be correct, because when executing the RefreshLink method, the error 3031 occures.
 

namliam

The Mailman - AWF VIP
Local time
Today, 08:55
Joined
Aug 11, 2003
Messages
11,695
I understand your problem, however your code is almost identical to mine for AXP
Code:
    tblDB = "D:\YourDB.MDB"
    For Each tbl In CurrentDb.TableDefs()
        If tbl.Attributes = dbAttachedTable Then
            If tbl.Connect <> ";Database=" & tblDB Then
                tbl.Connect = ";Database=" & tblDB
                tbl.RefreshLink
            End If
        End If
    Next tbl

Only difference, the check for the attached table. Even if your (visible) tables are all linked, the Tabledefs collection also holds sys tables which are local tables and cannot have a connect nor can they be relinked.
 

carpeneda

Carpeneda
Local time
Today, 07:55
Joined
Mar 5, 2009
Messages
9
I found out that the RefreshLink methode is working well, in case that I use a database file type 'mdb' instead of 'accdb'. It seems to me that my DAO libary is an old version from e.g. Access 2003, but My Access version is from 2007.
How can I update my Access DAO? Is there any update service available?
Thanks for any idea!
 

Users who are viewing this thread

Top Bottom