AutoNumber versus form record number

X

XP

Using Office 2003 and Windows XP;

I have a bound form. The table the form is bound to contains an AutoNumber
column named Num which is also a primary key for the table.

As the form is scrolled, the record number of course, changes.

1) Is the record number shown on the form ALWAYS equal to the AutoNumber
generated for that record in the table?

2) Is there a way to obtain the record number (shown in the form)? If so,
what would the code look like to return this number in a variable?

Thanks much in advance.
 
M

mscertified

(1) If you have the control bound to the autonumber field.
(2) variable = controlname (of autonumber control)
 
K

Klatuu

First, Autonumber should never contain meaningful information and not shown
on a form. Autonumbers should only be used for primary and foreign keys to
relate records in tables.

The record number you see in the navigation bar is also a meaningless
number. It only shows the relative postition of the record in the recordset.
If you add records, delete records, or reorder records, the number will
change relative to the recordset, so they really can't be used for anything
useful.

You can retrieve the record's relative record number, but again, it has no
real meaning. Here is how:

Dim lngRecNo as Long

lngRecNo = Me.Recordset.AbsolutePosition

Maybe if you could explain your objective, we could offer some suggestions.
 

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