Create a text box that automatically counts in forms

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am creating a data entry form and I would like to have a claim# for each
entry I would like the claim# to be something like CCA-1 and then count from
there on so the second entry would be CCA-2. Can someone tell me how to do
this in forms?
 
Is that field the primary key to your record?
If so, I would define the column as an autonumber in your table.
You will then get an auto-incrementing number on the form.
If the 'CCA' is to be a constant, it is superfluous, just put 'CCA' as the
caption for the control.

Dorian
 
If the number is to be seen by the user, I would not use autonumber, since
there will almost ineveitably be gaps in the number sequence. If the gaps
don't matter then there is probably no need to see the number at all, since
it is meaningless.

See
http://www.rogersaccesslibrary.com/download3.asp?SampleName=AutonumberProblem.mdb
for one method of adding an incrementing number using code. Another thing
you could do would be to add a number field (indexed, no duplicates - I will
call it IncrementingNum) to the table, then to bind a text box (I will call
it txtIncrement) on a form to that field. Something like the following as
the default value for txtIncrement will add an incrementing value to the
number field:
=Nz(DMax("IncrementingNum","tblMain"))+1

Use your own field and table names, of course.

Then, in an unbound text box on the form, set its control source to:
="CCA-" & [IncrementingNum]
 
No it is actually and unbound item on my form.

mscertified said:
Is that field the primary key to your record?
If so, I would define the column as an autonumber in your table.
You will then get an auto-incrementing number on the form.
If the 'CCA' is to be a constant, it is superfluous, just put 'CCA' as the
caption for the control.

Dorian
 
Back
Top