Results 1 to 4 of 4
  1. #1
    Join Date
    Dec 2020
    Posts
    2

    Unhappy Append query only adding one record meeting criteria rather than all records

    I have a form [frmPBGC] with a combobox [cmbPBGCbrand].
    Once a user makes a selection within the combobox, the onclick event of a command button within the form runs an append query.
    The goal is for the append query to add records to [PBGC] from [PBII] where the combobox selection matches a field in [PBII]. There are multiple records in [PBII] which contain a value equal to the combobox selection but for some reason only the first matching record in [PBII] appends to [PBGC]. Code below, any advice appreciated.




    Code:
    INSERT INTO PBGC ( BRAND, DESCRIPTION, UNITUPC, OLDRETAIL, NEWRETAIL )
    SELECT PBII.Group, PBII.Description, PBII.UnitUPC, PBII.ActiveRetail, [Forms]![frmPBGC]![txtPBGCNEW] AS Expr1
    FROM PBII LEFT JOIN PBGC ON PBII.Group = PBGC.BRAND
    WHERE (((PBII.Group) Like [Forms]![frmPBGC]![cmbPBGCbrand]));

  2. #2
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,914
    Why are you using Like if you want Equal?

    Run the Select query on it's own and see what is returned.
    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

  3. #3
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,914
    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

  4. #4
    Join Date
    Dec 2020
    Posts
    2
    The advice here helped point me in the right direction. My PBGC.BRAND was set as the primary key. Changing the primary key to a field that will contain unique values produced the result I was needing to see. I am building something rather complicated with no formal training and I am piecing everything together through lots of trial and error. Thanks for all the replies and sorry to waste everyone's time with something so basic.

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

Similar Threads

  1. Replies: 11
    Last Post: 04-13-2020, 02:13 AM
  2. Replies: 2
    Last Post: 04-21-2017, 01:15 PM
  3. Adding Dates to Meeting's Invitations
    By Lou_Reed in forum Access
    Replies: 0
    Last Post: 03-24-2017, 02:30 PM
  4. Form that only shows records meeting criteria?
    By Nick Lingenfelter in forum Forms
    Replies: 1
    Last Post: 12-05-2012, 02:15 PM
  5. Replies: 3
    Last Post: 10-25-2011, 11:38 PM

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