Simamd, do as Olaf suggests - if the grid represents the "natural" order of the underlying table or cursor.
If, on the other hand, the table has an index in force, and you want to show a consecutive row number (rather than the underlying record number), then setting the ControlSource to RECNO() won't give you that. Instead, you should add a field to the table, and populate it with consecutive numbers; then show that field as usual in the grid.
To populate the field with consecutive numbers, write a loop; each time round the loop, replace the field with an integer; start the integer at zero, and increment it by one each time round the loop. Do that immediately after setting the index.
Mike
__________________________________
Mike Lewis (Edinburgh, Scotland)
I just want to add, on top of the recno not being in order, if an index order is set, the recno also has no deeper meaning and is even no key to a record, because after a PACK the recno of the same record can change. RECNO is only of temporary meaning and can be used to eg initialize an ID integer autoinc field. You should add a primary key to any table.
I would also suggest to not even use that ID primary key field for reference on reports, on screen or via phone, that should always be a secondary unique key, the records primary key is best a kept secret for inner working of all applications involved.
That's a very strict opinion on the matter and can be seen relaxed anyway, but be prepared to see something fail, if you rely on a recno as permanent reference to something. If you merely wanted to see how to display something different than a field value in the grid, fine, if you merely want this for current reference or orientation, also fine.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.