Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how could i display tables record number in grid new column

Status
Not open for further replies.

slmamd

Programmer
Jul 16, 2013
13
SA
Hi all

help please ..

how could i feed table record number to new created grid column .. grammatically

regards
 
You would need to set the colum.controlsource = "(recno('alias'))"

Bye, Olaf.
 
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)

Visual FoxPro articles, tips and downloads
 
thanks a lot

...........OlafDoschke............
...........mike...................

it's working fine now......
 
Fine,

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.

Bye, Olaf.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top