John,
OK! Thank you very much up to this milestone, let me check other forms and reports. If there is some error or confusion i will most probably try to figure it out myself and try to resolve the logic you gave me. Else i'll knock your door and disturb you again.
Thanks again,
Khalid
---In MS_Access_Professionals@yahoogroups.com, <JohnV@...> wrote :
Khalid-
When you have duplicate cartons, one can use the number suffix, but the others should use letters. It's also OK to use letters for all the duplicates. When you assign numbers only, that's the same as multiple products in ONE carton, so the query is eliminating them.
Yes, I understand that CartonSuffix is text, but if the first digit is a number, then the query effectively groups all in the same CartonNo as one to get the correct count.
So, the rule is:
Use numbers for multiple products in a carton.
Use letters for duplicate cartons moved from another consignment. If duplicate cartons with letters have multiple products, use a letter and a number.
John Viescas, Author
Microsoft Access 2010 Inside Out
Microsoft Access 2007 Inside Out
Microsoft Access 2003 Inside Out
Building Microsoft Access Applications
SQL Queries for Mere Mortals
(Paris, France)
On Oct 23, 2014, at 12:25 PM, khalidtanweerburrah@... [MS_Access_Professionals] <MS_Access_Professionals@yahoogroups.com> wrote:John,First of all thanks indeed for being so supportive and generous for this help and guidance.As you pointed out why i am getting ClientName from tbl CollectionVoucher i removed it from it, as it was my mistake while you told me before no table should have duplicate fields RULE NO. 1, only Pkey's can be part of other tables.Then i modified your both queries slightly after removing ClientName from tbl CollectionVoucher.qryGroupCartons:SELECT CollectionVoucher.ConsigneeID, CollectionVoucher.ConsignmentNo, CollectionVoucher.ClientCIN, CollectionVoucher.Destination, Sum(CollectionVoucher.WeightOfCarton) AS Weight, CollectionVoucher.ExportDocs, CollectionVoucher.CartonNo, IIf(IsNumeric(Left(CollectionVoucher.CartonSuffix,1)),"",Left(CollectionVoucher.CartonSuffix,1)) AS CartonSuffixFROM CollectionVoucherWHERE (((CollectionVoucher.ConsignmentNo)=[Forms]![Dialog Consignment Delivery Note]![cmbConsignmentNo]))GROUP BY CollectionVoucher.ConsigneeID, CollectionVoucher.ConsignmentNo, CollectionVoucher.ClientCIN, CollectionVoucher.Destination, CollectionVoucher.ExportDocs, CollectionVoucher.CartonNo, IIf(IsNumeric(Left(CollectionVoucher.CartonSuffix,1)),"",Left(CollectionVoucher.CartonSuffix,1));Consignment Delivery Note Query:SELECT qryGroupCartons.ConsignmentNo, qryGroupCartons.ClientCIN, Clients.ClientName, Consignee.ConsigneeName, qryGroupCartons.Destination, Count(qryGroupCartons.CartonNo) AS TotalCartons, Sum(qryGroupCartons.Weight) AS TotalWeight, qryGroupCartons.ExportDocsFROM (Consignee INNER JOIN qryGroupCartons ON Consignee.ConsigneeID = qryGroupCartons.ConsigneeID) INNER JOIN Clients ON (Consignee.ConsigneeID = Clients.ConsigneeID) AND (qryGroupCartons.ClientCIN = Clients.ClientCIN)GROUP BY qryGroupCartons.ConsignmentNo, qryGroupCartons.ClientCIN, Clients.ClientName, Consignee.ConsigneeName, qryGroupCartons.Destination, qryGroupCartons.ExportDocs;-----------------------------------------Now one thing i'm not getting that in qryGroupCartons last line of sqlIIf(IsNumeric(Left(CollectionVoucher.CartonSuffix,1)),"",Left(CollectionVoucher.CartonSuffix,1));Why you used IsNumeric ?Field CartonSuffix is Text, and its Default Value is set to 0 (Should it be ZERO ?)Secondly, now the report is OK, BUT i'm confused in CartonSuffix. On my previously entered data for ConsignmentNo 2014-A-05, ClientCIN 15 has delivered 81 cartons.CartonNo 1 - 36 have been received against DeliveryVr 075CartonNo 1 - 45 have been received against DeliveryVr 084Duplicate CartonNo are from 1 - 36If i assign CartonSuffix for these 1 - 36 duplicate cartons as below the report is OK.CartonNo CartonSuffix1 A1 B2 A2 Bup to CartonNo 3636 A36 BRemaining37 038 039 040 041 042 043 044 045 0But if i assign CartonSuffix as 0,1 OR 1,2 for CartonNo 1 -36, remaining 37 - 45 CartonSuffix as 0, then report shows Total Cartons for this Client = 45.In this scenario what way i should adopt to assign CartonSuffix?The delay in replying you was this issue, which i was checking.Once lot of thanks up to here.Khalid
---In MS_Access_Professionals@yahoogroups.com, <JohnV@...> wrote :Khalid-Sorry I missed the bracket!I assume you're now also using CartonSuffix with letters to indicate cartons moved from another assignment with duplicates. For example, if a carton 1 was moved, its CartonSuffix would be A1. If a moved Carton has multiple products, then you would use A2, A3, etc.First, build a query on CollectionVoucher that "pre-groups" the cartons containing multiple products:qryGroupCartons:SELECT ConsigneeID, ConsignmentNo, ClientCIN, ClientName, Destination, Sum(WeightOfCarton) As Weight, ExportDocs, CartonNo, IIf(IsNumeric(Left(CollectionVoucher.CartonSuffix, 1)), "", Left(CollectionVoucher.CartonSuffix, 1)) As CartonSuffixFROM CollectionVoucherWHERE (((CollectionVoucher.ConsignmentNo)=[Forms]![Dialog Consignment Delivery Note]![cmbConsignmentNo]))GROUP BY ConsigneeID, ConsignmentNo, ClientCIN, ClientName, Destination, ExportDocs, CartonNo, IIf(IsNumeric(Left(CollectionVoucher.CartonSuffix, 1)), "", Left(CollectionVoucher.CartonSuffix, 1));Now substitute this query in your final query:SELECT qryGroupCartons.ConsignmentNo, qryGroupCartons.ClientCIN, qryGroupCartons.ClientName, Consignee.ConsigneeName, qryGroupCartons.Destination, Count(qryGroupCartons.CartonNo) AS TotalCartons, Sum(qryGroupCartons.Weight) AS TotalWeight, qryGroupCartons.ExportDocsFROM Consignee INNER JOIN qryGroupCartons ON Consignee.ConsigneeID = qryGroupCartons.ConsigneeIDGROUP BY qryGroupCartons.ConsignmentNo, qryGroupCartons.ClientCIN, qryGroupCartons.ClientName, Consignee.ConsigneeName, qryGroupCartons.Destination, qryGroupCartons.ExportDocs;The first query groups the rows in CollectionVoucher by CartonNo and "" when the CartonSuffix is just a number and by CartonNo and the letter when the CartonNo contains a letter indicating a duplicate CartonNo. Your final query now counts the rows grouped by the first query.By the way, why are you getting ClientName from CollectionVoucher? I would think ClientName would appear in the Clients table linked by ClientCIN. When you introduce a duplicate field like this, you make your data subject to errors if the name gets misspelled when entered in the second table. This would mean an additional join to the Clients table to get the name, but you avoid any data entry errors.John Viescas, AuthorMicrosoft Access 2010 Inside OutMicrosoft Access 2007 Inside OutMicrosoft Access 2003 Inside OutBuilding Microsoft Access ApplicationsSQL Queries for Mere Mortals(Paris, France)On Oct 23, 2014, at 8:41 AM, khalidtanweerburrah@... [MS_Access_Professionals] <MS_Access_Professionals@yahoogroups.com> wrote:John,Sorry that i was missing left bracket [ before CartonSuffix. Its OK now.Now coming to one of a report "Consignment Delivery Note" its Record Source is a query with sql:SELECT CollectionVoucher.ConsignmentNo, CollectionVoucher.ClientCIN, CollectionVoucher.ClientName, Consignee.ConsigneeName, CollectionVoucher.Destination, Count(CollectionVoucher.CartonNo) AS TotalCartons, Sum(CollectionVoucher.WeightOfCarton) AS TotalWeight, CollectionVoucher.ExportDocsFROM Consignee INNER JOIN CollectionVoucher ON Consignee.ConsigneeID = CollectionVoucher.ConsigneeIDGROUP BY CollectionVoucher.ConsignmentNo, CollectionVoucher.ClientCIN, CollectionVoucher.ClientName, Consignee.ConsigneeName, CollectionVoucher.Destination, CollectionVoucher.ExportDocsHAVING (((CollectionVoucher.ConsignmentNo)=[Forms]![Dialog Consignment Delivery Note]![cmbConsignmentNo]));I have entered some test data for ClientCIN 2CartonNo CartonSuffix1 12 13 13 23 3CartonNo 3 containing three different ProductsNow on the Report i need that it should show me Total Cartons for this Client THREE i.e CartonNo 1,2 & 3but i get Total Cartons = 5 which is count of CartonNoSorting and Grouping is of Report is:Destination --- Group Header -- YesClientCIN --- Group Header -- NoTotalCartons ---- Group Header -- NoWhere i'm wrong? and what should i do to get Report as i need?table CollectionVoucher has Pkey ConsignmentNo, ClientCIN, CartonNo and CartonSuffixKhalid
---In MS_Access_Professionals@yahoogroups.com, <JohnV@...> wrote :Khalid-OK, my mistake. Something is missing in your criteria. Try adding a Debug.Print stLinkCriteria after you assign the predicate. You can see the result in the Immediate Window. (CTRL+G)John Viescas, AuthorMicrosoft Access 2010 Inside OutMicrosoft Access 2007 Inside OutMicrosoft Access 2003 Inside OutBuilding Microsoft Access ApplicationsSQL Queries for Mere Mortals(Paris, France)
P.S. When replying on the web, click Show Message History at the bottom of the message area so I can see previous replies in email. I have to keep going back to the group website to look at previous answers.On Oct 21, 2014, at 2:48 PM, khalidtanweerburrah@... [MS_Access_Professionals] <MS_Access_Professionals@yahoogroups.com> wrote:John,No! ClientCIN is number and CartonNo is number.ConsignmentNo is TextDeliveryVr is TextCartonSuffix is TextKhalid
__._,_.___
Posted by: khalidtanweerburrah@yahoo.com
Reply via web post | • | Reply to sender | • | Reply to group | • | Start a New Topic | • | Messages in this topic (25) |
.
__,_._,___
Tidak ada komentar:
Posting Komentar