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,608 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 141 Reputation points MVP
    2024-02-17T01:34:43.3866667+00:00

    Hi Greg. That seems very odd as the action taken by the Access team on 30 Jan should have solved this as long as Access really was restarted. I'm not able to go into details but I know how this was done!

    It may be worth checking that you don't have a hidden instance of Access lurking in Task Manager Background Processes. As I'm sure you are aware, that can happen if an app doesn't close correctly and leaves a lock file in place.

    If there is a background copy of Access still open, then you won't actually be restarting Access and so you won't get the fix.

    If even that fails, can you reboot and try again then report back.

    On the (hopefully) unlikely event that this issue remains, please provide the 2312 build number next to About Access (not the MSO build number you see if you click that button as it may be different).


  2. Colin Riddington 141 Reputation points MVP
    2024-02-20T12:06:33.12+00:00

    Perhaps those that have restarted no longer see the error but haven't told you? I'm happy to contact the Access team again but, before I do so, can you please try to pin this down: a) Have you tried restarting Access and testing a version without the error handling b) Can you ask a selected user or user(s) to do the same with a modified version


  3. Jean-Philippe George 0 Reputation points
    2024-02-22T10:07:31.29+00:00

    Hello,

    My users are on Monthly Channel, new version arrived for some of them on Monday the 19 of february.

    As soon as they have the Version 2312 Build 16.0.17126.20190) 32 bits the bug happen. I restarted one pc, check that one and only one Access is running, the bug is still there. I tried to update Office, no update for the moment. As soon as I downgrade to Version 2311 Build 16.0.17029.20140) 32 bits it works again

    Semi annual Version 2308 Build 16.0.16731.20542) 32-bit works too.

    Thanks to all for the infos


  4. Calu Florent 0 Reputation points
    2024-03-01T09:55:47.92+00:00
    Hello everyone. I have the same error problem. "Erreur d'execution 3283.
    La clé principale existe déja." with the RefreshLink() function. 
    Version 2312 ( Build17126.20190 - french )
    RefreshLink with ODBC table.
    
    0 comments No comments