Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7895229
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T07:35:33+00:00 2026-06-03T07:35:33+00:00

I found a good method of getting the next 4 digit number. How to

  • 0

I found a good method of getting the next 4 digit number.
How to find next free unique 4-digit number

But in my case I want to get next available 4 or 5 digit number.
And this will change depending upon the users request. Theses number are not a key ID columns, but they are essential to the tagging structure for the business purpose.

Currently I use a table adabpter query. But how would I write a query.
I suppose I could do a long iterative loop through all values until I see a 4 digit.

But I’m trying to think of something more efficient.

Function GetNextAvailableNumber(NumofDigits) as Long
'SQL Code Here ----
'Query Number Table

Return Long


End Function

Here’s my current SQL:

'This Queries my View
SELECT MIN([Number]) AS Expr1
FROM  LineNumbersNotUsed

'This is my View SQL 
SELECT Numbers.Number
FROM Numbers
WHERE (((Exists (Select * From LineList Where LineList.LineNum =  Numbers.Number))=False))
ORDER BY Numbers.Number;

Numbers is the List of All available number from 0 to 99999, basically what’s available to use.

LineList is my final master table where I keep the long and all the relevant other business information.

Hopefully this make sense.

Gosh you guys are so tough on new guys.
I accidentally hit the enter key, and the question posted and I instantly get -3 votes.

Give a new guy a break will you! Please.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T07:35:34+00:00Added an answer on June 3, 2026 at 7:35 am

    I apologize in advance in case I overlooked something in your question. Using your design, won’t a query like this return the next unused 4 digit number?

    SELECT MIN([Number]) AS next_number
    FROM  LineNumbersNotUsed
    WHERE
            [Number] > 999
        AND [Number] < 10000;
    

    This approach is not adequate with multiple concurrent users, but you didn’t indicate that is an issue for you.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I found some good answers for this question, but I can't really get them
I've searched and found a good discussion here on SO , but it is
I've searched around but haven't found any good examples or tutorials of saving audio
i know every web-developer hates this topic, but anyway... i found no good solution
I was browsing and found good articles about encryption. However, none of them described
I've searched the Internet and have found some good solutions for teeing STDOUT to
Did some searches here & on the 'net and haven't found a good answer
This problem pops around the network for years, I've found no good solution yet.
I don't know how to do this, and I've found no good resources online
I haven't found a very good answer to my problem so I'm starting a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.