Capture Record number as a field in form

B

babs

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
 
R

Rick B

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.
 
B

BruceM

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.
 

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