Page 1 of 2 12 LastLast
Results 1 to 15 of 28
  1. #1
    hokie is offline Novice
    Windows XP Access 2003
    Join Date
    Jul 2009
    Posts
    20

    duplicate problem

    I have a database with duplicate invoice numbers and that is not a problem. The problem is the shipping charge for each of the duplicates has the total shipping charge for each one so if I have 5 duplicate invoice numbers the shipping rate is 4 times too much. Is there any way I can have a query or macro find these duplicates and delete all the shipping charges except for the first one.


    Edit: Also not every record has a shipping charge so I assume I need an iif statement that says if there is a shipping charge then do all of the above otherwise do nothing. I want the field to stay just change the 4 of the 5 duplicates to zero. Any help would be appreciated.
    Last edited by hokie; 07-08-2009 at 09:07 AM. Reason: more detail

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    You may wish to review the structure of your tables as this indicates a fundamental problem but the Query Wizard can create a "Find Duplicate Record" query.

  3. #3
    hokie is offline Novice
    Windows XP Access 2003
    Join Date
    Jul 2009
    Posts
    20
    I can find the duplicate entries but I wanted to automate a way to only have the 1st instance shown for the field [shipping charge] and the other duplicate fields to remain but the [shipping charge] to be set to zero instead of $50.
    ie. I have 5 lines with the same invoice # and the shipping charge should be $50 for the entire invoice but because of the way the system I get my information from(small business threw this database together) it comes up with $50.00 shipping for each of the 5 lines overstating shipping charge by $200.00.

    The reason this has to be done is because there are 2 seperate databases the information is coming from and matching up based on an order number. One is internal the other is external and the problem lies in the external reporting. Hope this cleared it up.

    Thanks for your reply.

  4. #4
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Is this for a report? What does the RecordSource SQL look like?

  5. #5
    hokie is offline Novice
    Windows XP Access 2003
    Join Date
    Jul 2009
    Posts
    20
    The end results will go into a report. I did everything from the GUI side but here is the SQL code from the query.

    SELECT Dropship.*, SupplierZone.[Invoice Date], SupplierZone.[Vendor #], SupplierZone.Total, SupplierZone.Difference, SupplierZone.Name, SupplierZone.CodeDate, SupplierZone.InvoiceNumber, SupplierZone.Freight, SupplierZone.Handling
    FROM Dropship INNER JOIN SupplierZone ON Dropship.[Order#] = SupplierZone.[Order#];


    The SupplierZone.Freight and SupplierZone.Handling are the fields I need to have only 1 charge when there is a duplicate invoice number. I hope this helps.

    Thanks again

  6. #6
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    So you are totaling these values on a report?

  7. #7
    hokie is offline Novice
    Windows XP Access 2003
    Join Date
    Jul 2009
    Posts
    20
    Yes I am using this report to total these 2 fields mentioned in the post above.

  8. #8
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Will setting the Hide Duplicates property of the control to YES work for you?

  9. #9
    hokie is offline Novice
    Windows XP Access 2003
    Join Date
    Jul 2009
    Posts
    20
    That will not work for my situation because there are situations where the shipping or handling will be the same as a different invoice that should be calculated in the total.

  10. #10
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    It sounds like you will need code in the Detail_Print event. If there are more than one detail line with the same invoice number, does the first record *always* have the values you need? In other words, can we jjst hide all of the subsequent charges for the same invoice?

  11. #11
    hokie is offline Novice
    Windows XP Access 2003
    Join Date
    Jul 2009
    Posts
    20
    Yes that would work perfect. The 1st line of the duplicate invoices always has the correct total amount for that invoice. Should I just look up "Detail_Print event" in a google search because I have not used this before. I have an access for dummies book i'll look it up in there in the meantime.

    Thanks for all your help.

  12. #12
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    We need the actoal control names for these three fields: InvoiceNumber, Freight, Handling. It would be nice if thenames were txtInvoiceNumber, txtFreight, txtHandling.

  13. #13
    hokie is offline Novice
    Windows XP Access 2003
    Join Date
    Jul 2009
    Posts
    20
    The names are InvoiceNumber, Freight, Handling. InvoiceNumber is a text field the others are numbers.

  14. #14
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Please change the names of the controls to what I suggested so there is no confusion referencing them. I'll create the code for you.

  15. #15
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Then you need to get to the event tab of the properties sheet for the Detail Section and press the "..." button and select code. Then *replace* the stub of code provided with the following:
    Code:
    Option Compare Database
    Option Explicit
    Dim LastInvoiceNumber As String
    Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
       If Me.txtInvoiceNumber = LastInvoiceNumber Then
          Me.txtFreight.Visible = False
          Me.txtHandling.Visible = False
       Else
          LastInvoiceNumber = Me.txtInvoiceNumber
          Me.txtFreight.Visible = True
          Me.txtHandling.Visible = True
       End If
    End Sub

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. duplicate autonumber
    By rayc in forum Access
    Replies: 5
    Last Post: 06-19-2013, 07:50 AM
  2. Duplicate first row
    By kruai in forum Access
    Replies: 1
    Last Post: 06-22-2009, 02:06 PM
  3. Need Duplicate List Box
    By newbie in forum Forms
    Replies: 7
    Last Post: 05-11-2009, 09:45 AM
  4. Duplicate add to new table
    By horseyshoe in forum Access
    Replies: 3
    Last Post: 09-01-2006, 07:51 AM
  5. Which duplicate?
    By grgerhard in forum Import/Export Data
    Replies: 1
    Last Post: 05-27-2006, 06:19 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