Results 1 to 6 of 6
  1. #1
    paulbioc is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Oct 2017
    Posts
    4

    Exclamation HELP! lost the primary key record and cannot open the other related table

    I cancelled by mistake the n1 record of primary key and now I cannot activate the related table..... can someone help me please!

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,926
    Did not have cascade delete in relationship so you have orphan records now?

    Is the primary key field an autonumber type? It is possible to use an INSERT sql action to create this record with the deleted primary key value. Then must run Compact & Repair on the db to reset the PK seed value.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    paulbioc is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Oct 2017
    Posts
    4
    Hi June7! Tnx a lot! I'm not an expert... how should I do to INSERT sql?

  4. #4
    paulbioc is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Oct 2017
    Posts
    4
    Hi June7! Tnx a lot! I'm not an expert... how should I do to INSERT sql?

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,926
    I use VBA, can even do this in the VBA immediate window. Suggest you test on a copy of the db.

    CurrentDb.Execute "INSERT INTO tablename (your pk field) VALUES (the missing number)"

    Or build a query object with that SQL.

    However, if any other fields are set as Required, this will fail. You will have to include those other fields in the SQL with appropriate values.

    CurrentDb.Execute "INSERT INTO tablename (your pk field, atextfield, adatefield, anumberfield) VALUES (the missing pk, "sometext", #somedate#, number)"
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  6. #6
    paulbioc is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Oct 2017
    Posts
    4
    Thanks a lot! I will try.....

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 3
    Last Post: 04-09-2014, 12:48 PM
  2. Replies: 5
    Last Post: 02-16-2014, 02:50 PM
  3. Go To Record with related table Primary Key
    By jamiebull21 in forum Forms
    Replies: 3
    Last Post: 02-17-2012, 09:36 AM
  4. Replies: 11
    Last Post: 11-13-2011, 06:57 PM
  5. Replies: 2
    Last Post: 10-19-2011, 06:47 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums