Help creating a number generator

N

Nathan

I need to create a database that will create a number field with a fixed
number of digits. The idea is to be able to number pre-printed forms with a
numeric sequence. I also need to be able to specify the start and stop
number for the report. I think I can figure that out, but what I need is
help with creating the number generator in VBL or SQL. Please note again
that I need a fixed number of digits. That is to say something like eight
digits so that if the actual value is less than eight digits, then the
balance of the number is preceeded by zeros.
 
M

M.L. Sco Scofield

Take a look at:

http://support.microsoft.com/default.aspx?scid=kb;en-us;210194
http://support.microsoft.com/default.aspx?scid=kb;en-us;240317

To pad the number with leading zeros, there are a couple of different ways.
The one I use is:

Format(lngYourNumber, "00000000")

Good luck.

Sco

M.L. "Sco" Scofield, Microsoft Access MVP, MCSD, MCP, MSS, A+
Denver Area Access Users Group Vice President www.DAAUG.org
MS Colorado Events Administrator www.MSColoradoEvents.com
Useful Metric Conversion #18 of 19: 8 nickels = 2 paradigms (My personal
favorite)
Miscellaneous Access and VB "stuff" at www.ScoBiz.com
 
N

Nathan

Thanks, I think I understand it, however, where do I put the format line in,
and does it go as you have typed it there or is what is in parentheses for
my benefit? Thanks
 
M

M.L. Sco Scofield

In the code in article #240317, I'd replace:

NextKeyValue = TempKeyValue

with:

NextKeyValue = Format(TempKeyValue, "00000000")

Good luck.

Sco

M.L. "Sco" Scofield, Microsoft Access MVP, MCSD, MCP, MSS, A+
Denver Area Access Users Group Vice President www.DAAUG.org
MS Colorado Events Administrator www.MSColoradoEvents.com
Useful Metric Conversion #18 of 19: 8 nickels = 2 paradigms (My personal
favorite)
Miscellaneous Access and VB "stuff" at www.ScoBiz.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top