473,385 Members | 1,492 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

How to assign the available number in a sequence.

I am using Access 2007.

I have a table which has a field called priority which may or may not have a number value in it. I want to be able to click on this record in a form have have the lowest available number assigned to it. I know how to assign the next number, but can't figure out how to assign the lowest available number. What I mean is that records may have been deleted after a number was assigned to them, so now there are gaps in the sequence such as 1,2,3,5. In this example I want VBA to assign this record I have clicked on the number 4 as it is the lowest available number. Can anyone help?
Oct 29 '12 #1
2 1892
zmbd
5,501 Expert Mod 4TB
Do you have a primary key?
Oct 29 '12 #2
Rabbit
12,516 Expert Mod 8TB
Do a ranking query. Join the query to itself on the first row to the next row. Calculate the gap. Return the minimum number where the gap is greater than 1.
Oct 29 '12 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Ken1 | last post by:
I am going to drop a primary key from one column and create a new column to be used as primary key in an existing database. The old column was a date column which someone earlier though was a good...
3
by: pluton | last post by:
Hallo, Hot to get unique, sequential number during execution of stored procedure ? I can create table with autoincrement column, add record, get ident_current and delete record each time i...
4
by: pjac | last post by:
I need assistance in creating an Automatic tracking number that appears in a textbox that looks like: 2004-001. The first part of the number is based on the year, the second part is generated from...
13
by: Ron | last post by:
Hi all I'm deciding whether to use the PK also as an account number, invoice number, transaction number, etc that the user will see for the respective files. I understand that sometimes a...
2
by: Chapai | last post by:
Hi all! I need your help to realize algorithm for stored proc or trigger. tool: SQL TABLE:
3
by: peddie | last post by:
Hi, I have a table that contains two key fields. I would like to assign the auto number for the secondary key field by starting from 1. For example primary Key id second Key Id...
5
by: Eric E | last post by:
Hi, I have a question about sequences. I need a field to have values with no holes in the sequence. However, the values do not need to be in order. My users will draw a number or numbers from...
2
by: argniw | last post by:
I need to assign a different random number to each record in one column in one table in access. How can i do this?
8
by: Wayne L | last post by:
I have searched and could not find my solution to my problem. I have a table that has a field that I want to start at 0001 and go to 1999. Once it reaches 1999 I want the field to reset to 0001. I...
2
dlite922
by: dlite922 | last post by:
Hey Guys, I'm a PHP guy, but choose to do my file scripts in perl and have come upon this problem: I have n files with a date in their name: test2010-08-23.txt for example. I want grab...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.