Results 1 to 6 of 6
  1. #1
    philipscodes is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2014
    Location
    Dubai
    Posts
    20

    Mark Duplicate Records

    Greetings Experts,

    I have a Access DB where I store sales data from our CRM server.
    I base this DB for all my Excel calculations/reports via MS Query.
    We sell cars.

    The sales table in Access has a field 'CREDITED_INVOICE' that maintains a manual entry as of now, to differentiate between the actual invoice and the credited invoice.
    From the report that the CRM provides, the only way to know if the invoice was credited and re-invoiced is via the latest system generated Invoice number 'INV_No'.
    So, while the Access table stores both the credited and new invoice, it will obviously have a duplicate entry in the Chassis (VIN number) field.

    My requirement:
    The 'CREDITED_INVOICE' field should always store the value 'INVOICED' when a fresh CRM report is uploaded to the Access table.
    However, when Access notices a duplicate CHASSIS, it should mark the value 'CREDITED' instead on all the previous records - (by observing the Older Invoice Number).

    Warm Regards,


    Philip
    Attached Thumbnails Attached Thumbnails CreditInvoice.PNG  

  2. #2
    aytee111 is offline Competent At Times
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    I assume a file is imported into the database and the table is then updated? If so, this will be two queries, one to append all the records, the second to join the two tables on VIN number and update the one to Credited. Altho I am not sure how you would identify which record to update, is it the one with the highest invoice number?

  3. #3
    philipscodes is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2014
    Location
    Dubai
    Posts
    20
    Yes, That's right - highest Invoice number.
    Will an Aggregate query work with Max on the Invoice number? I saw this solution from another similar thread.
    Then a query for updating to 'CREDITED' can be used.

    Regards,
    Philip

  4. #4
    aytee111 is offline Competent At Times
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    Totals queries cannot be used in updating. There are other ways of doing it, such as using DMax, doing it in VBA, making a temp table, etc.

  5. #5
    philipscodes is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2014
    Location
    Dubai
    Posts
    20
    Hi Aytee111,

    Could you kindly advise me using the DMax method on this particular case?
    I am good at VBA solutions but would like to avoid it as much as possible.

    Thanks,
    Philip

  6. #6
    Join Date
    Apr 2017
    Posts
    1,679
    Create a saved query
    qLastInvoice = SELECT inv.Chassis, MAX(inv.INV_NO) AS LastInvoice FROM AL_Invoice_AN6 inv GROUP BY inv.Chassis;

    and another one
    uqInvoices =
    UPDATE (AL_INVOICE_AN6 inv LEFT JOIN qLastInvoice li ON li.Chassis = inv.Chassis AND li.LastInvoice = inv.INV_NO)
    SET Credited_Deal = "CREDITED"
    WHERE li.Chassis = Null

    Now run the second query.

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

Similar Threads

  1. Replies: 2
    Last Post: 11-08-2017, 09:04 AM
  2. Duplicate Records
    By TimC in forum Queries
    Replies: 2
    Last Post: 12-22-2014, 07:52 AM
  3. Replies: 3
    Last Post: 03-22-2014, 04:32 PM
  4. Duplicate Records
    By MTSPEER in forum Access
    Replies: 2
    Last Post: 06-05-2013, 09:07 AM
  5. Duplicate Records
    By softspoken in forum Queries
    Replies: 3
    Last Post: 06-21-2010, 03:33 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