Microsoft Access Forums

Go Back   Microsoft Access Forums > Access Forums > Access

Reply
 
LinkBack Thread Tools Display Modes
  #1  
Old 07-08-2009, 07:04 AM
hokie hokie is offline Windows XP Access 2003 (version 11.0)
Novice
 
Join Date: Jul 2009
Posts: 20
hokie is on a distinguished road
Default 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 07:07 AM. Reason: more detail
Reply With Quote
  #2  
Old 07-08-2009, 08:15 AM
RuralGuy's Avatar
RuralGuy RuralGuy is online now Windows 7 Access 2007 (version 12.0)
Administrator
 
Join Date: Mar 2007
Location: 8300' in the Colorado Rocky Mountains
Posts: 4,263
RuralGuy will become famous soon enoughRuralGuy will become famous soon enough
Default

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.
__________________
(RG for short) aka Allan Bunch MS Access MVP - WinXP Pro, Win7 - acXP, ac07
If your issue is resolved...follow this link for directions on how to use the Solved thread tool!
Teaching is not filling a bucket but lighting a fire. Borrowed quote..."Docendo discimus"
Reply With Quote
  #3  
Old 07-08-2009, 09:02 AM
hokie hokie is offline Windows XP Access 2003 (version 11.0)
Novice
 
Join Date: Jul 2009
Posts: 20
hokie is on a distinguished road
Default

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.
Reply With Quote
  #4  
Old 07-08-2009, 12:55 PM
RuralGuy's Avatar
RuralGuy RuralGuy is online now Windows 7 Access 2007 (version 12.0)
Administrator
 
Join Date: Mar 2007
Location: 8300' in the Colorado Rocky Mountains
Posts: 4,263
RuralGuy will become famous soon enoughRuralGuy will become famous soon enough
Default

Is this for a report? What does the RecordSource SQL look like?
__________________
(RG for short) aka Allan Bunch MS Access MVP - WinXP Pro, Win7 - acXP, ac07
If your issue is resolved...follow this link for directions on how to use the Solved thread tool!
Teaching is not filling a bucket but lighting a fire. Borrowed quote..."Docendo discimus"
Reply With Quote
  #5  
Old 07-08-2009, 01:04 PM
hokie hokie is offline Windows XP Access 2003 (version 11.0)
Novice
 
Join Date: Jul 2009
Posts: 20
hokie is on a distinguished road
Default

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
Reply With Quote
  #6  
Old 07-08-2009, 01:12 PM
RuralGuy's Avatar
RuralGuy RuralGuy is online now Windows 7 Access 2007 (version 12.0)
Administrator
 
Join Date: Mar 2007
Location: 8300' in the Colorado Rocky Mountains
Posts: 4,263
RuralGuy will become famous soon enoughRuralGuy will become famous soon enough
Default

So you are totaling these values on a report?
__________________
(RG for short) aka Allan Bunch MS Access MVP - WinXP Pro, Win7 - acXP, ac07
If your issue is resolved...follow this link for directions on how to use the Solved thread tool!
Teaching is not filling a bucket but lighting a fire. Borrowed quote..."Docendo discimus"
Reply With Quote
  #7  
Old 07-13-2009, 05:18 AM
hokie hokie is offline Windows XP Access 2003 (version 11.0)
Novice
 
Join Date: Jul 2009
Posts: 20
hokie is on a distinguished road
Default

Yes I am using this report to total these 2 fields mentioned in the post above.
Reply With Quote
  #8  
Old 07-13-2009, 05:24 AM
RuralGuy's Avatar
RuralGuy RuralGuy is online now Windows 7 Access 2007 (version 12.0)
Administrator
 
Join Date: Mar 2007
Location: 8300' in the Colorado Rocky Mountains
Posts: 4,263
RuralGuy will become famous soon enoughRuralGuy will become famous soon enough
Default

Will setting the Hide Duplicates property of the control to YES work for you?
__________________
(RG for short) aka Allan Bunch MS Access MVP - WinXP Pro, Win7 - acXP, ac07
If your issue is resolved...follow this link for directions on how to use the Solved thread tool!
Teaching is not filling a bucket but lighting a fire. Borrowed quote..."Docendo discimus"
Reply With Quote
  #9  
Old 07-13-2009, 06:29 AM
hokie hokie is offline Windows XP Access 2003 (version 11.0)
Novice
 
Join Date: Jul 2009
Posts: 20
hokie is on a distinguished road
Default

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.
Reply With Quote
  #10  
Old 07-13-2009, 06:42 AM
RuralGuy's Avatar
RuralGuy RuralGuy is online now Windows 7 Access 2007 (version 12.0)
Administrator
 
Join Date: Mar 2007
Location: 8300' in the Colorado Rocky Mountains
Posts: 4,263
RuralGuy will become famous soon enoughRuralGuy will become famous soon enough
Default

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?
__________________
(RG for short) aka Allan Bunch MS Access MVP - WinXP Pro, Win7 - acXP, ac07
If your issue is resolved...follow this link for directions on how to use the Solved thread tool!
Teaching is not filling a bucket but lighting a fire. Borrowed quote..."Docendo discimus"
Reply With Quote
  #11  
Old 07-13-2009, 07:02 AM
hokie hokie is offline Windows XP Access 2003 (version 11.0)
Novice
 
Join Date: Jul 2009
Posts: 20
hokie is on a distinguished road
Default

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.
Reply With Quote
  #12  
Old 07-13-2009, 07:12 AM
RuralGuy's Avatar
RuralGuy RuralGuy is online now Windows 7 Access 2007 (version 12.0)
Administrator
 
Join Date: Mar 2007
Location: 8300' in the Colorado Rocky Mountains
Posts: 4,263
RuralGuy will become famous soon enoughRuralGuy will become famous soon enough
Default

We need the actoal control names for these three fields: InvoiceNumber, Freight, Handling. It would be nice if thenames were txtInvoiceNumber, txtFreight, txtHandling.
__________________
(RG for short) aka Allan Bunch MS Access MVP - WinXP Pro, Win7 - acXP, ac07
If your issue is resolved...follow this link for directions on how to use the Solved thread tool!
Teaching is not filling a bucket but lighting a fire. Borrowed quote..."Docendo discimus"
Reply With Quote
  #13  
Old 07-13-2009, 07:34 AM
hokie hokie is offline Windows XP Access 2003 (version 11.0)
Novice
 
Join Date: Jul 2009
Posts: 20
hokie is on a distinguished road
Default

The names are InvoiceNumber, Freight, Handling. InvoiceNumber is a text field the others are numbers.
Reply With Quote
  #14  
Old 07-13-2009, 07:51 AM
RuralGuy's Avatar
RuralGuy RuralGuy is online now Windows 7 Access 2007 (version 12.0)
Administrator
 
Join Date: Mar 2007
Location: 8300' in the Colorado Rocky Mountains
Posts: 4,263
RuralGuy will become famous soon enoughRuralGuy will become famous soon enough
Default

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.
__________________
(RG for short) aka Allan Bunch MS Access MVP - WinXP Pro, Win7 - acXP, ac07
If your issue is resolved...follow this link for directions on how to use the Solved thread tool!
Teaching is not filling a bucket but lighting a fire. Borrowed quote..."Docendo discimus"
Reply With Quote
  #15  
Old 07-13-2009, 07:59 AM
RuralGuy's Avatar
RuralGuy RuralGuy is online now Windows 7 Access 2007 (version 12.0)
Administrator
 
Join Date: Mar 2007
Location: 8300' in the Colorado Rocky Mountains
Posts: 4,263
RuralGuy will become famous soon enoughRuralGuy will become famous soon enough
Default

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
__________________
(RG for short) aka Allan Bunch MS Access MVP - WinXP Pro, Win7 - acXP, ac07
If your issue is resolved...follow this link for directions on how to use the Solved thread tool!
Teaching is not filling a bucket but lighting a fire. Borrowed quote..."Docendo discimus"
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Duplicate first row kruai Access 1 06-22-2009 12:06 PM
Need Duplicate List Box newbie Forms 7 05-11-2009 07:45 AM
Duplicate add to new table horseyshoe Access 3 09-01-2006 05:51 AM
Which duplicate? grgerhard Import/Export Data 1 05-27-2006 04:19 AM
duplicate autonumber rayc Access 0 01-16-2006 06:57 AM


All times are GMT -8. The time now is 02:39 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.