473,385 Members | 1,546 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.

Creating Unique "File Number" Generation

Hi,
I am looking to finish up a database that I have created by adding a feature to customize a "file number" or ID assigned for each new customer being added based on input from user at time of creation(ie the user selects the category and db assigns it a file# with specified prefix); account type/prefixes are "50" or "30" followed by a four digit running number "####". My questions are, will it be possible for me to have two different types account numbers being automatically generated from the same back end? How do I ensure that no "File Numbers" are skipped? Any tips for reducing the occurrence of duplicates?
Jan 14 '20 #1
2 1408
cactusdata
214 Expert 128KB
Let your form create the number.
To prevent dupes, either apply a unique index on the field in the table and catch the error if a dupe is attempted to be saved, or, before saving it, verify that it doesn't already exist.
Jan 14 '20 #2
NeoPa
32,556 Expert Mod 16PB
Yes it's possible to have a single sequential set of numbers split across two different Type codes. EG. 300001, 300002, 500003, 300004, 500005, 500006, 300007, 500008, etc.

Some typical VBA code for setting the next required value, in this case assuming the Type code to be "50" :
Expand|Select|Wrap|Line Numbers
  1. strType = "50"
  2. strNext = strType & Format(Val(Nz(DMax(Expr:="Right([IDField],4)" _
  3.                                      , Domain:="[YourTable]"), "0")) + 1, "0000")
Numbers should never be skipped unless records are deleted later on.

If you have a scenario where multiple users can add records at the same time then you can either put code in to check for duplicates after an item has been added or you can set a separate field just for the sequential number and set that as a unique index. Obviously the main ID field would be a unique index too.
Jan 14 '20 #3

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

Similar topics

39
by: Dave Theese | last post by:
Hello all, We're presented with the problem of needing to generate a unique file name. I've had some thoughts, but also wanted to solicit suggestions from the group. Any suggestions for...
3
by: Darrel | last post by:
I have a table that stores the content for a web site I'm making. Each one has a unique ID so I can grab it via the querystring. Since it's being done via a query string, I didn't want to use...
5
by: Greg Corradini | last post by:
Hello All, I'm attempting to create multiple dictionaries at once, each with unique variable names. The number of dictionaries i need to create depends on the length of a list, which was returned...
3
by: travis.downs | last post by:
Hi, I'm trying to use a macro to create a unique temporary variable name, such as #define TEMP_OBJ(string) MyType obj_ <some magic here(string); So something like TEMP_OBJ("foo")
11
by: breal | last post by:
I have three lists... for instance a = ; b = ; c = ; I want to take those and end up with all of the combinations they create like the following lists
4
by: mopiforu | last post by:
HI, I am creating a web server in which user will upload a file, in my cgi script using the upload method i am getting the file handle and writing the file in my hard drive, later am using the...
0
by: Rajesh Kumar Joshi | last post by:
I have a table with only 1 column as Table : profileTable //-------------- profile XML; //-------------- A sample content of XML file is <sampleprofile name="joe" version="A123">...
13
by: mliptak | last post by:
I'm trying to implement logging in my application, so that each log message has its unique identifier, e.g. log(identifier, text) What I want to achieve is that the compiler screams if the log()...
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

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.