Solved Autonumber counter that starts from 1 (1 Viewer)

FahadTiger

Member
Local time
Today, 16:30
Joined
Jun 20, 2021
Messages
115
Hi Experts..
I have orderT contains OrderID and OrderName
I want OrderID start from 1 .. every entering 100 records in OrderName
thanks for all
 

silentwolf

Active member
Local time
Today, 06:30
Joined
Jun 12, 2009
Messages
545
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
 

FahadTiger

Member
Local time
Today, 16:30
Joined
Jun 20, 2021
Messages
115
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
 

plog

Banishment Pending
Local time
Today, 08:30
Joined
May 11, 2011
Messages
11,611
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.
 

plog

Banishment Pending
Local time
Today, 08:30
Joined
May 11, 2011
Messages
11,611
Then enter a 100 records. What does this custom number have to do with anything?
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 08:30
Joined
Feb 28, 2001
Messages
26,999
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.
 

FahadTiger

Member
Local time
Today, 16:30
Joined
Jun 20, 2021
Messages
115

Attachments

  • order number.PNG
    order number.PNG
    4.5 KB · Views: 62

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 08:30
Joined
Feb 28, 2001
Messages
26,999
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?
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 09:30
Joined
Feb 19, 2002
Messages
42,970
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.
 

FahadTiger

Member
Local time
Today, 16:30
Joined
Jun 20, 2021
Messages
115
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

Top Bottom