473,394 Members | 1,755 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,394 software developers and data experts.

Custom Number Format

I am working on a project using Access 2003. I am using the Autonumber as an ID generator, and I want it to be random. I want to format it to 5 digits, but I can't get it to work. I have made all the numbers positive, but the desired size doesn't work. How can I make the length of the autonumber 5 digits? If the answer is to use VBA coding, please be specific, because the team members on this project are beginners in linking VBA to access. Thank you.

UAlbanyMBA
Nov 10 '06 #1
3 7034
southoz
24
Good ay UAlbanyMBA

well straight from the manual & vb help files
Int((upperbound - lowerbound + 1) * Rnd + lowerbound)
Here, upperbound is the highest number in the range, and lowerbound is the lowest number in the range.
Before calling Rnd, use the Randomize statement without an argument to initialize the random-number generator with a seed based on the system timer.

have fun
southoz
Nov 10 '06 #2
NeoPa
32,556 Expert Mod 16PB
AutoNumber is specifically for generating IDs in records, generally for use as a PK.
SouthOz's answer provides you with a way to generate random numbers to fit your requirement.
What do you mean about storing as 5 didgits?
Numbers are not stored as any specific number of digits - that is only used for display.
To show a number as a five digit string use Format(number, "00000") (unless this is within a SQL string when the format string would be written as '00000' instead.
Nov 11 '06 #3
MMcCarthy
14,534 Expert Mod 8TB
AutoNumber is specifically for generating IDs in records, generally for use as a PK.
SouthOz's answer provides you with a way to generate random numbers to fit your requirement.
What do you mean about storing as 5 didgits?
Numbers are not stored as any specific number of digits - that is only used for display.
To show a number as a five digit string use Format(number, "00000") (unless this is within a SQL string when the format string would be written as '00000' instead.
And if you want to do this at table design level simply put five 0's in the Format property of the field in design view.

00000

No quotes required
Nov 12 '06 #4

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

Similar topics

7
by: netclectic | last post by:
Hi folks, i've searched and searched and can't find any example of what i'm trying to do. Essentially (i think) i need to add a new operator to Number. I'm using eval to evaluate expressions...
22
by: Dariusz Kuliński / TaKeDa | last post by:
I guess that was asked milion times, but I don't have good luck finding working answer on google. Most of the answers tell what to do, but not how. My situation is that I want to have ID in...
0
by: berg | last post by:
All, I am binding an ArrayList full of custom objects to an DataGrid. The property in the custom class are all public. I define a DataGridTableStyle and set the MappingName to "ArrayList". I...
22
by: TC | last post by:
I have an Access database application with a lot of custom row functions written in VBA. In other words, a lot of queries contain calculated fields which use functions defined in the modules. I...
0
by: msnews.Microsoft.com | last post by:
Hi , Not able to figure out the way to format numeric fields. Code snippet Dim ColStyle3 As New DataGridTextBoxColumn With ColStyle3
7
by: Flashster | last post by:
My program writes text to a file. Currently the files have a suffix of '.log' . I want to make sure that the user does not attempt to open a file that was not originally created by my program. ...
27
by: Wayne | last post by:
I've been clicking around Access 2007 Beta 2 and can't see the custom menu bar designer. Is it in the beta? Maybe I'm blind. The question that comes to mind is: Will custom menu bars be the same...
2
by: KA NMC | last post by:
I've noticed something strange when using the code below with a DateTimePicker wondering anyone else noticed or knows why this happens Dim ws As String ws = "Not Available" ...
5
by: troy_lee | last post by:
I have a table that has a PK field with the following format: Dyymm123. So that, a typical number might look like this D0806270. The first character is literal and never changes. The next four...
2
Pittaman
by: Pittaman | last post by:
Hello I am creating some crystal reports (for visual studio 2005) based on the content of certain .NET objects. I'm doing this in .NET 2.0. For one of them I'm using a Cross-table to summarize...
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...
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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,...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.