Results 1 to 8 of 8
  1. #1
    rwahdan1978 is offline Advanced Beginner
    Windows 11 Access 2016
    Join Date
    Jun 2024
    Posts
    57

    How to insert new records using the query insert

    Hi



    I am tring to create a query of type append to insert new records into existing table!

    I choose the table and current database then I put all the fields that I need to insert. Now, I don't know what to put in the caretria of each filed. I tried to put the form fields but nothing happened! What Am I missing? Should I include the primary key or what?

    Click image for larger version. 

Name:	Screenshot 2024-08-20 133125.jpg 
Views:	24 
Size:	107.3 KB 
ID:	52133

  2. #2
    ano is offline Competent Performer
    Windows 11 Office 365
    Join Date
    Nov 2023
    Posts
    204
    u not need a query to update ur table. the query is for manual or vba insert. if u look at ur qry (sql view) it copy it self !
    new form with ur table invoiceid is hidden dataview (many records ) or form view (1 record) thats all

  3. #3
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,932
    When you click the append button you are prompted for a table name and it looks like you are trying to append the same data to the same table and since the invoiceID is a PK it would create duplicates which are not allowed. i.e. they are not new records.

    Suggest explain exactly what you are trying to do - provide some example data, where does this come from, etc.

    If using a form bound to the table appends happen automatically.

    If importing data from another table then that is what should appear in the top part of the window

  4. #4
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,556
    You never include the autonumber field for an append.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  5. #5
    ano is offline Competent Performer
    Windows 11 Office 365
    Join Date
    Nov 2023
    Posts
    204
    "t would create duplicates which are not allowed." cj im amazed u say this. he did not include PK so they are added anyway without errors!!!

  6. #6
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,932
    I was referring to the OP's comment in post #1 - 'Should I include the primary key or what?'

  7. #7
    ano is offline Competent Performer
    Windows 11 Office 365
    Join Date
    Nov 2023
    Posts
    204
    Quote Originally Posted by CJ_London View Post
    I was referring to the OP's comment in post #1 - 'Should I include the primary key or what?'
    even after several rereads from the questions and ur answers i still confused ur answer because i would answer like welsgasman with the note that PK is autonumber so pk never added in an append / insert . perhaps uk dialect read it as u ment . but i did not .but tnx for the explanation

  8. #8
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,932
    no problem - my response was directed to the OP. I hadn't seen your response when posted

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

Similar Threads

  1. Replies: 7
    Last Post: 05-10-2019, 10:40 PM
  2. Replies: 1
    Last Post: 08-29-2016, 07:50 PM
  3. Replies: 3
    Last Post: 05-27-2015, 01:04 PM
  4. INSERT query: insert new data only
    By drh in forum Access
    Replies: 2
    Last Post: 04-04-2014, 05:31 PM
  5. Replies: 2
    Last Post: 05-03-2011, 01:02 AM

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