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).
When I run RefreshLink, I get an error saying "Primary key already exists"
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
9 additional answers
Sort by: Most helpful
-
Colin Riddington 141 Reputation points MVP
Feb 15, 2024, 2:11 AM 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:
- Right click context menu
- Linked table manager
- 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
-
Colin Riddington 141 Reputation points MVP
Feb 15, 2024, 7:34 AM 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
-
Colin Riddington 141 Reputation points MVP
Feb 28, 2024, 8:14 AM 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
-
Dukes, Yossi 0 Reputation points
Feb 15, 2024, 3:29 AM 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.