Create Code on Long Integer Field

A

Andrew

Is it possible to use the expression builder to build a sequential numbering
system by lets say setting a default value on a long integer field
(ReportNumber) to1000000 and using the expresion builder (Access 2007) to ad
the Auto number generated to that 10000000? Ex. [Reports].[ID] is auto
number, + [Reports].[IDR] is set at 1000000 so the first report
[Reports].[IDR]=1000001
 
B

Brendan Reynolds

Andrew said:
Is it possible to use the expression builder to build a sequential
numbering
system by lets say setting a default value on a long integer field
(ReportNumber) to1000000 and using the expresion builder (Access 2007) to
ad
the Auto number generated to that 10000000? Ex. [Reports].[ID] is auto
number, + [Reports].[IDR] is set at 1000000 so the first report
[Reports].[IDR]=1000001


Not in the table, if that's what you mean, but it could be done in a query,
form, or report. In a query, it would look something like so ...

SomeAlias: [SomeField] + [SomeOtherField]

.... or, to account for possible Null values ...

SomeAlias: NZ([SomeField], 0) + NZ([SomeOtherField], 0)

In the control source of a text box on a form or report it would look
something like so ...

=NZ([SomeField], 0) + NZ([SomeOtherField], 0)
 
D

Damon Heron

I don't know why you would want to add the autonumber to anything. Even
though it is sequential, there are instances where it jumps around and comes
up with a non-sequential number ( like filling in the numbers that were used
and deleted). If you want a sequential numbering system starting with 1mil,
you are on the right track however. Set the first record's IDR value at
1000000.

Open the report in design view. The unload event:
Dim NewIDR As Long
NewIDR = DMax("idr", "tblreports") + 1
DoCmd.RunSQL "Insert into tblreports (IDR) values(" & [NewIDR] & ")"
'the above updates the number sequence by 1 in the table

.. In the report's Header, use a textbox with the control source:
= DMax("[IDR]","TblReports")

This will show your latest number sequence.

Damon
 

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