Results 1 to 2 of 2
  1. #1
    Elisa is offline Novice
    Windows XP Access 2003
    Join Date
    Dec 2009
    Posts
    1

    Stumped on an INSERT

    Hi,

    I'm stumped.

    To recreate the "problem"...

    New database... New Table called tblKeys ... One column/field , numeric , make it the primary key so no duplicates.

    In a new VBA module....

    Sub subInsertRec()
    Dim db As Database
    Set db = CurrentDb
    db.Execute "insert into tblkeys (key) values ( 123 );"
    Set db = Nothing
    End Sub

    Run the procedure at least 2 times.

    The first time... A record is added.
    The second time... No record added but *no errors*!!!

    I'd like to catch the addition of duplicate records.



    Any answers much much much appreciated.

    TIA
    Elisa

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows XP Access 2002
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Try:
    db.Execute "insert into tblkeys (key) values ( 123 );" ,dbFailOnError

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

Similar Threads

  1. Insert only permission?
    By wordracr in forum Security
    Replies: 1
    Last Post: 01-14-2010, 04:48 PM
  2. Just insert new data
    By watzmann in forum Access
    Replies: 1
    Last Post: 11-29-2009, 11:48 AM
  3. help with insert
    By jamie in forum Access
    Replies: 1
    Last Post: 11-16-2009, 06:02 AM
  4. automatic row insert
    By Jerry8989 in forum Forms
    Replies: 7
    Last Post: 09-29-2009, 06:50 AM
  5. Insert a picture with macro
    By KWarzala in forum Forms
    Replies: 8
    Last Post: 09-23-2009, 08:43 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