OrderID Generator

latex88

Registered User.
Local time
Today, 16:30
Joined
Jul 10, 2003
Messages
198
How do I create it in VB that I can set an OrderID to 1 for the very first order for the day, then generate the OrderID to add 1 for the following order? I'd presume I have to create it in a public function? It should be simple, but I'm jut not there yet in programming VB. I would appreciate the whole DIM line and the function lines. Thanks.
 
There are more than one to do this, and all have advantages and disadvantages. Besides the seq. number, what else makes up the OrderID? Are you storing the bits of the Order Number in seperate fields and just generating the Order each time you need to display it?
 
The OrderID will be tied to each order so that modification to a specific Order can be modified when called. A count of total orders can also be calulated at the end of the day.
 
Ok Assume Order Seq ID is in a seperate field, because OrderID would be a BAD name for it since you would OrderID 1 each day if I understand.
One way that is simplestic, is to do a COUNT(OrderID) where OrderDate = Today and then add one to that. If there are no orders, it returns zero (+1) gives you 1 for the first one of the day. The problem with this approach is the time lag between starting an order and storing it in the database might allow duplicate Seq. numbers with a shared DB. Another approach would be to have a parmater table and in that have the daily SEQ number last used and the DATE you are working on. If the date is not equal to TODAY, Reset to 1 and update the date. If the date is equal, grab the number, add 1 to it, update the parameter table and drive on. I usually like to write a function to handle the SEQ number. THis approach has little time between getting the number and updating it. Still not 100% against duplicates, but I have used this approach many times and have yet to have a duplicate generated, even with 8 users on the system.
 

Users who are viewing this thread

Back
Top Bottom