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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Code needed to give a unique ID number to each row. 1

Status
Not open for further replies.

elevator

Programmer
Apr 23, 2002
19
US
Need code to give ID number to each row. The list is huge so each row needs it's own unique ID number. Using Paradox 10.

Have this
---------
Name...Rate..Type..ID#
N 10 g
C 2 g
D 4 o
B 8 m
J 7 m

Need this
---------
N 10 g 1
C 2 g 2
D 4 o 3
B 8 m 4
J 7 m 5
 
Have you tried just adding an autoincrement field? This will give each record and individual number, similar to what you have listed.

Have fun,

Woody.
 
Although the autoincrement field would work fine in most cases, it can cause problems with linked data - especially in data recovery situations. I use a seperate table that contains the next number in a series. I grab it using a tCursor, write it to the new record, then increment it so it's ready for the next record.

Mac :)

"Do not delve too deeply in the arts of your enemy and so become ensnared by them"

langley_mckelvy@cd4.co.harris.tx.us
 
Elevator,

IF this is a one-shot, meaning you won't have to run it again, *and* no one else will be using the table while you're assigning the numbers, then something like this should work:

Code:
var
   tc  Tcursor
endVar

   tc.open( "tablename" )
   tc.edit()
   scan tc :
      tc."FieldName" = tc.recNo()
      tc.unlockRecord()
   endScan
   tc.endEdit()
   tc.close()

Now, that is very quick and dirty; it contains no error-checking and assumes a great deal. (Don't forget to replace "tablename" with the name of your table and "FiledNAme" withg the name of the field. Yes, both values need to be in quotes.)

IF, however, you're looking for something to maintain your record number while multiple users are entering data, then you're want to use MAc's approach *or* take a look at RDA's AutoKey product (see for details).

Hope this helps...

-- Lance
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top