473,769 Members | 1,748 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to populate sequential numbers in a field using SQL or VBA?

Hi,

Is there a way to populate sequential numbers in a field using SQL or
VBA? If yes, how?

Assume the following is my existing table:

Fruit ID
Apply
Banana
..
..
Orange

and I want to populate the ID field with 100, 101, 102.....

(I do not want to use append query with autonumber field.)

Excel 009

Jun 27 '08 #1
3 4692

"Excel 009" <ex***********@ gmail.comwrote in message
news:87******** *************** ***********@w1g 2000prd.googleg roups.com...
Hi,

Is there a way to populate sequential numbers in a field using SQL or
VBA? If yes, how?

Assume the following is my existing table:

Fruit ID
Apply
Banana
.
.
Orange

and I want to populate the ID field with 100, 101, 102.....

(I do not want to use append query with autonumber field.)

Excel 009
Create a Temp table with 2 fields
1) AutoNumber
2) Keyvalue

Use a append query to fill the temp table's [KeyValue] with the primary key
value of you data table.
Run an update query using the AutoNumber to fill the ID field
([AutoNumber]-1) + 100.
Jun 27 '08 #2
x = 100

Do While Not rst.EOF

rst.edit
rst![ID] = x
rst.update

x = x +1
rst.movenext
Loop

"Excel 009" <ex***********@ gmail.comwrote in message
news:87******** *************** ***********@w1g 2000prd.googleg roups.com...
Hi,

Is there a way to populate sequential numbers in a field using SQL or
VBA? If yes, how?

Assume the following is my existing table:

Fruit ID
Apply
Banana
.
.
Orange

and I want to populate the ID field with 100, 101, 102.....

(I do not want to use append query with autonumber field.)

Excel 009

Jun 27 '08 #3
Thanks guys! I will experiment with each of the methods you guys
provide and let you know.

Anyone has a new idea, please feel free to provide. Thanks.

Excel 009
Jun 27 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
12711
by: Jenn L | last post by:
I have a database that is pre-populated with sequential part numbers. As people reserve the parts I update a flag to show the # is no longer available. Now they want the ability to take out a block of "x" number of sequential part numbers - say for example 5. If my database had the following numbers available: 101 104 105 110
5
3209
by: Lapchien | last post by:
I have list of numbers in a table (originally from autonumber in a different database) from 1 to 1,000,000. The list is not in sequential order - there are loads of numbers missing. How can I identify what numbers are missing? Thanks, Lap (I'd like to then use this 'missing number list' to use for new records, instead of autonumber - I think I need to use DMax - can someone summarise
14
12048
by: amywolfie | last post by:
Hi All: I know this is simple, but I just can't seem to get there: I need to sort a table by a text field (txtDescription), then assign sequential numbers to the field SEQUENCE in table. Every time a new record is added, the all SEQUENCE #'s must be reset. The re-numbering will be triggered by an EXPORT button.
4
3106
by: bill.brennum | last post by:
Hi, This is probably a question with a simple answer, but here goes. I have a form linked to a table. There is a field on that table that while not showing on the form, I would like to populate via a lookup using either a popup or subform. This is an employee name match application that will allow a user to lookup a corporate employee and assign them to an unmatched person.
2
1767
by: Mike Kingscott | last post by:
Hi all, I'd building an app that posts to a web service. One of the things that is required in the soap header is a sequential number appended to a ref, i.e. "IGI1001", "IGI1002", etc. Obviously the first part of the reference ("IGI") stays the same, but I need an incrementing number generated. Now, I was thinking of doing this via a SQL database, but it would be an awful waste as there would only be one table and one stored procedure...
2
5119
by: John | last post by:
Hi I need to assign sequential invoice numbers to orders starting from the last highest number + 1. I have tried the following code; UPDATE Orders SET Orders. = DMax("","Orders")+1 WHERE Orders.) Is Null AND ... The problem is that all orders get the same number which is the last highest number + 1. Apparently the query does not recalculate DMax("","Orders")+1 for each record and instead only gets the value once in the
4
2093
by: Bruce | last post by:
Surely someone has done this before, and I am guessing there is a simple solution that is eluding me. I have a simple report based on a recordset. For each record there is a field (RecNum) that is basically a sequential number from 1 to n. Occasionally there are skips between numbers. I would like to print 'record skipped' for each record missing from the sequence. For example, if there were no records numbered 5 and 6 in a sequence...
1
2455
maxamis4
by: maxamis4 | last post by:
Hello folks, I have two forms a parent form and a subform. The parent form is an unbound form while the subform is a form that contains all a list of what I like to call 'in stock ' phone numbers. with in that subform the user has the ability to select between to radio buttons to do a bulk selection. The first option lets the user select the first X amount of numbers that he or she wants. The second option selects X amount of numbers but...
9
2948
by: Axxe | last post by:
I have searched high and low for cogent, well-explained coding to complete a project on which I have spent six months of work. I stumbled across something on this site that is close to what I seek, but, as is rather typical, I could understand neither the question nor the answer. I am hopeful that someone in this forum can provide me with suitable guidance. THE ISSUE I am working in Access 2003. The database I am preparing...
0
9423
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10212
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10047
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9995
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8872
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7410
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
3962
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3563
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2815
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.