When I run RefreshLink, I get an error saying "Primary key already exists"

mk 25 Reputation points
2024-01-10T05:12:16.54+00:00
I'm using Visual Studio 2019's Visual Basic.
To reconnect the link table of the Access file,
The reference is set to "Microsoft Office 16.0 Access database engine Object Library".
When using this to set a new connection destination and execute RefreshLink, an error message "Primary key already exists" will now occur.
I was able to successfully reconnect the link table until January 5, 2024.
I have asked this question because an error suddenly started appearing on January 9, 2024.
 
Dim dao1 As Object
Dim dao2 As Object

dao1 = New Microsoft.Office.Interop.Access.Dao.DBEngine
dao2 = dao1.OpenDatabase(Access file path)

for loop = 0 To dao2.TableDefs.Count - 1
     dao2.TableDefs(loop).Connect = Reconnect destination
     dao2.TableDefs(loop).RefreshLink()
next
VB
VB
An object-oriented programming language developed by Microsoft that is implemented on the .NET Framework. Previously known as Visual Basic .NET.
2,583 questions
{count} vote

Accepted answer
  1. BaDi 90 Reputation points
    2024-01-11T15:06:22.7566667+00:00

    I have the same problem and it is related to the Office update 2312 which was released on 5 January. As a workaround, you could switch back to a previous version of Office (e.g. 2311).

    3 people found this answer helpful.

9 additional answers

Sort by: Most helpful
  1. Colin Riddington 136 Reputation points MVP
    2024-02-15T02:11:34.7633333+00:00

    Ann alerted me to this thread by email

    The issue I reported a couple of months ago with error 3611 is definitely fixed.

    I’m now on v2403 Beta Channel  I’ve just tried refreshing links to SQL Server tables using the following methods:

    1. Right click context menu
    2. Linked table manager
    3. VBA

    All succeeded with no errors  Happy to alert the Access team even though I can’t replicate the issue I'll report back when I hear anything useful

    Apologies for the double post. The first reply didn't appear at first so I re-sent it  

    1 person found this answer helpful.
    0 comments No comments

  2. Colin Riddington 136 Reputation points MVP
    2024-02-15T07:34:51.4933333+00:00

    I have already had a reply from the Access team who informed me that this issue should already have been resolved. On further checking, the 3283 refresh link error was first reported to the Access team on 29 Jan & fixed within 24 hours! Users just need to close and restart Access for the fix to take effect. No version update required. If your users aren't reporting the error it is probably because they have already restarted Access

    1 person found this answer helpful.
    0 comments No comments

  3. Colin Riddington 136 Reputation points MVP
    2024-02-28T08:14:34.13+00:00

    Hi Greg. You're welcome. With hindsight this explanation was obvious but it baffled me for several weeks when I knew it was fixed in the current channel. I would have expected the remotely applied fix to apply to the slower monthly enterprise channel as well, but in this case at least, that didn't happen. For info, there is also now a blog article at https://www.accessforever.org/post/refreshlink-fails-with-primary-key-already-exists

    1 person found this answer helpful.

  4. Dukes, Yossi 0 Reputation points
    2024-02-15T03:29:35.7766667+00:00

    Using the Linked Table Manager will allow the relinking to succeed. We are doing the relinking and reindexing process via vba. When we perform a tdf.RefreshLink we still get the error "Primary Key Already Exists" This is using 3212 in our DEV environment When we perform the exact same process in our Production environment 3211, no errors occur. This is still a problem which needs to be fixed asap.