This might be somewhat of a duplicate of a thread titled "table not sorting properly". (I'm still a newby so it won't let me post the link)
What I've gathered from that thread is that tables have no inherent sorting applied to them. They are just a jumbled container for your data, and the only way to sort this data is by using a query. Am i correct in saying this?
If what I said above is the case, do dao recordsets work the same as queries? As in, will they actually sort data the way i tell them to?
The reason i ask is I've been tasked to generate a running totals report for another department. The goal is to use a table from our MRP system that defines all actions required for a part. For example it contains records for each part number that tell you when you need to buy a part and how much you need to buy (adds to the running total), when that part needs to be sold or to be used as a component for building another part (subtracts from the running total) all based current demand, lead times, etc...
I have like 120ish lines of code that i wrote and the logic is all there and it works. The way it works is it loops through the recordset (which selects all records from a table called tblTotals) which is sorted by part number, then date, then action type (buy, make, sell, etc...). It then checks if the part number for the current record matches with the part number of the previous record, then adds or subtracts to the running total based on the action type of the current record. Once that value becomes negative, that means on that date we will be short the quantities that we need to fulfill the demand. Our purchasing group wants to use this so that they can see when that will happen ahead of time and can plan with our suppliers so that we are never short of what we need.
So once I find the records for each part where the quantity will go negative, it places the negative quantity and the date it will go negative into 2 fields for that record. i then run another query to select all records that have negative running totals and that is the data my purchasing/procurement group wants to see.
Herein lies the problem, I have reduced the number of records in my actions table for testing code's logic, and it works, most of the time... 9 times out of 10 i'll get the correct running total quantities and my only thought, since my code requires that the recordset be sorted properly, is that it isn't always sorting the way I'm expecting it to. Which means some records are appearing before others and it messes up the running total. One part number in particular will show the correct value (-53) 9 times out of 10. I'll come in the next morning and play around with it some more and all of a sudden it will show (-253).
So, do dao recordsets honor the order by clauses of the SQL statements you use to generate them?
What I've gathered from that thread is that tables have no inherent sorting applied to them. They are just a jumbled container for your data, and the only way to sort this data is by using a query. Am i correct in saying this?
If what I said above is the case, do dao recordsets work the same as queries? As in, will they actually sort data the way i tell them to?
The reason i ask is I've been tasked to generate a running totals report for another department. The goal is to use a table from our MRP system that defines all actions required for a part. For example it contains records for each part number that tell you when you need to buy a part and how much you need to buy (adds to the running total), when that part needs to be sold or to be used as a component for building another part (subtracts from the running total) all based current demand, lead times, etc...
I have like 120ish lines of code that i wrote and the logic is all there and it works. The way it works is it loops through the recordset (which selects all records from a table called tblTotals) which is sorted by part number, then date, then action type (buy, make, sell, etc...). It then checks if the part number for the current record matches with the part number of the previous record, then adds or subtracts to the running total based on the action type of the current record. Once that value becomes negative, that means on that date we will be short the quantities that we need to fulfill the demand. Our purchasing group wants to use this so that they can see when that will happen ahead of time and can plan with our suppliers so that we are never short of what we need.
So once I find the records for each part where the quantity will go negative, it places the negative quantity and the date it will go negative into 2 fields for that record. i then run another query to select all records that have negative running totals and that is the data my purchasing/procurement group wants to see.
Herein lies the problem, I have reduced the number of records in my actions table for testing code's logic, and it works, most of the time... 9 times out of 10 i'll get the correct running total quantities and my only thought, since my code requires that the recordset be sorted properly, is that it isn't always sorting the way I'm expecting it to. Which means some records are appearing before others and it messes up the running total. One part number in particular will show the correct value (-53) 9 times out of 10. I'll come in the next morning and play around with it some more and all of a sudden it will show (-253).
So, do dao recordsets honor the order by clauses of the SQL statements you use to generate them?