append sequential numbers in access table (1 Viewer)

hatmak

Registered User.
Local time
Today, 05:29
Joined
Jan 17, 2015
Messages
121
hi

please help in

append sequential numbers in access query or table ( this sequence is variable )

based in number I put it in form like

12500

I want add 500 record sequence like

12501
12502
12503
12504



to
13000

other example
110200000 add 100 Coupon

to 110200100
in attached example

in form tb

when I press in button Generate Coupon

make this sequence in table "all_Coupon"


thanks for help
 

Attachments

  • ex.accdb
    832 KB · Views: 417

theDBguy

I’m here to help
Staff member
Local time
Today, 05:29
Joined
Oct 29, 2018
Messages
21,467
Hi. Sounds like you could use a Tally table.

Sent from phone...
 

hatmak

Registered User.
Local time
Today, 05:29
Joined
Jan 17, 2015
Messages
121
any help
 

plog

Banishment Pending
Local time
Today, 07:29
Joined
May 11, 2011
Messages
11,643
This is pretty simple, even if you don't know VBA I suggest you give it a shot. I'll help by writing the psuedo code:

Code:
Sub AddCoupons()

for i=0 to Me.CouponCount
  DoCmd.RunSQL("INSERT INTO YourTable (CouponNumberField) VALUES (" & i + Me.CouponNumber " &")")
  Next i
End Sub

Again, that's pseudo code which means it illustrates the ideas you need in your code but not the exact syntax.
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 07:29
Joined
Feb 28, 2001
Messages
27,156
No doubt you DO have an error. I believe I counted 11 zeros there. That number is 100 Billion (USA nomenclature) which would cause an integer overflow. The largest number you can count using a LONG is 4.1 billion (approximately) or 2^32 -1. IF you are on a 32-bit machine, you are done because Access won't support the QUAD type if the hardware doesn't support it. If you are on a 64-bit machine AND have a relatively new version of Access, it is POSSIBLE to have a quadword integer that would support a number that large. If so, you could use a VBA loop like plog showed you. The other choice would be to count numbers that big using a CURRENCY data type.

Why do you want/need numbers that big anyway?
 

hatmak

Registered User.
Local time
Today, 05:29
Joined
Jan 17, 2015
Messages
121
No doubt you DO have an error. I believe I counted 11 zeros there. That number is 100 Billion (USA nomenclature) which would cause an integer overflow. The largest number you can count using a LONG is 4.1 billion (approximately) or 2^32 -1. IF you are on a 32-bit machine, you are done because Access won't support the QUAD type if the hardware doesn't support it. If you are on a 64-bit machine AND have a relatively new version of Access, it is POSSIBLE to have a quadword integer that would support a number that large. If so, you could use a VBA loop like plog showed you. The other choice would be to count numbers that big using a CURRENCY data type.

Why do you want/need numbers that big anyway?
thanks for reply

Why do you want/need numbers that big anyway?

because that number is used for coupon number like big sale or serial number that issue in big market
 

theDBguy

I’m here to help
Staff member
Local time
Today, 05:29
Joined
Oct 29, 2018
Messages
21,467
because that number is used for coupon number like big sale or serial number that issue in big market
I think @The_Doc_Man's point was, have you tried manually entering that number into your Access table? Did it work?

Otherwise, what data type were you planning to use to store that number?
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 08:29
Joined
Feb 19, 2002
Messages
43,257
Can you break this into two parts. A prefix and a suffix? You can increment them separately but it will get complicated.
 

Users who are viewing this thread

Top Bottom