Capture Record number as a field in form

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

Guest

There are a number of reason why I need the recordnumber as a field. Not
sure how to capture it. Do not want to put the code in the ONCurrent event
of the form- its it causing other issues. What code and where can I put it
to do this??

Thanks,
Barb
 
You don't. If you need a record number, then you should add a field to
create it. The "record number" you see can't be used reliably. If you have
25 records, and you delete 1, the record numbers all change. If you apply a
filter and limit the number of records you see in a form, report, or query,
then the "record numbers" change.

If you need a key field, then you need to add a field to your table, and
define it the way you'd like.
 
I'm not sure what you mean. If you mean you want the records to be numbered
sequentially, with no gaps unless you delete a record, one approach may be
found here:
http://www.rogersaccesslibrary.com/download3.asp?SampleName=AutonumberProblem.mdb
"Other issues" is vague. You could use a variant of Roger's code in a form
event, or a command button, or whatever:

If Me.NewRecord Then
Me.NumberField = Nz(DMax("[NumberField]", "tblYourTable")) + 1
End If

If you are talking about a report, you can number the records when the form
is displayed, independently of a stored number. Details needed.
 
Back
Top