Solved Autonumber counter that starts from 1

FahadTiger

Member
Local time
Today, 17:04
Joined
Jun 20, 2021
Messages
120
Hi Experts..
I have orderT contains OrderID and OrderName
I want OrderID start from 1 .. every entering 100 records in OrderName
thanks for all
 
Hi,
in the AutoNumber you can't and should not change it.
Better of having an "ORDER Number" besides the ORDERID which you change to what ever you like when certain OrderID is reached

So you have Order_ID=101, OrderNumber=1

but not sure why you like to go back with your OrderNumber?

HTH
 
Hi,
in the AutoNumber you can't and should not change it.
Better of having an "ORDER Number" besides the ORDERID which you change to what ever you like when certain OrderID is reached

So you have Order_ID=101, OrderNumber=1

but not sure why you like to go back with your OrderNumber?

HTH
thanks for reply
I mean Number Field not autonumber
orderID start from begining ever 100 records
 
Why do you want to do this? What does it do for your organization?

It serves no purpose for the database internally and actually goes againts good database design. Perhaps we can suggest a best-practices alternative if we fully understand what you are trying to accomplish with this.
 
Then enter a 100 records. What does this custom number have to do with anything?
 
If you MUST generate a number that goes from 1 to 100 repeatedly, then try this idea. When assigning the value of your new sequence number, include this expression, perhaps in the BeforeUpdate code, after you have validated everything else and have decided to allow the update.

Code:
NewSeq = 1 + ( ( DCount( "*", "OrderT" ) MOD 100  )


This will give you a number starting from 1, going to 100, and recycling. ONLY use this for new order numbers. Note that the concerns expressed by the other forum members are not wrong, but if you HAVE to do this, this is one simple way.
 

Attachments

  • order number.PNG
    order number.PNG
    4.5 KB · Views: 100
When you say mistack (probably mistake?) - what does it do? Also, I see this relates to form OrderName (or control Ordername), but the table is OrderT. The question is, which table actually HOLDS the newly created order number?
 
We probably need to step back from this for a moment and consider exactly HOW you will want to use this number. Are you going to want to have a select query that looks for every record with sequence #100? Do you need to treat each 100 records as a "set"?

I'm not sure that just going 1-100 and starting again is going to be helpful. I think at a minimum, you need to make "sets" of 100 records so you can identify an incomplete set if necessary or perhaps sum each set so you know that setA = $3455.45 and setB = $1982.20, etc.
 
If you MUST generate a number that goes from 1 to 100 repeatedly, then try this idea. When assigning the value of your new sequence number, include this expression, perhaps in the BeforeUpdate code, after you have validated everything else and have decided to allow the update.

Code:
NewSeq = 1 + ( ( DCount( "*", "OrderT" ) MOD 100  )


This will give you a number starting from 1, going to 100, and recycling. ONLY use this for new order numbers. Note that the concerns expressed by the other forum members are not wrong, but if you HAVE to do this, this is one simple way.
thank you Sir.. I used your code and doing perfect
 

Users who are viewing this thread

Back
Top Bottom