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

Recno() question

Status
Not open for further replies.

asm338s

Programmer
Joined
Jul 16, 2001
Messages
135
Location
US
Can I have a field in the table that has the record number. What I mean by that is that the field should be populated by the recno() function, like a sequential number which I later intend to use as a composite key. Or is there any other way that I can add a sequential field in a table.

Thanks
 
I would not use RECNO() as a unique record ID for the simple fact that, if you ever delete records, you will wind up with duplicate values. I would do this:

SELECT myTable
SET ORDER TO myIndex
GO BOTTOM
lnRecid = fieldvalue + 1
APPEND BLANK
REPLACE field WITH lnRecid
 
i am using alltrim(field1) + alltrim(field2) + alltrim(str(recno())) as primaryKey, but this still gives duplicate records and recno() skips numbers like it increments lilke 1,2,3,4 and then goes to 7 etc.

any help appreciated.
 
Hi spayne:

What is lnRecid(some variable that you defined),
and what is fieldValue(is that pkey),

I wrote this:

Select myTable
Set order to pkey
go bottom
scan
lnRecid = pkey + 1
append blank
replace pkey with lnRecid
endscan

 
I have a table which I named IDStore, which has one record that contains several the id number for several tables and other identification, such as corporate name and address for the project. These could be a part of an array if desired. Assuming your table is named "Master" add a field to the Master table named MasterNO Numeric 5 digits. Add an index to index on MasterNo. Include a field in IDStore named MasterNo, numeric 5 digits.
When you want to add a record to Master include the following code:

Select IDStore
m.MasterNo = IDStore.MasterNo + 1
Replace IDStore.MasterNo with m.MasterNo
select Master && assumes all memvar are set up for entry
insert into Master from memvar

Set order to tag MasterNo will display your records in the sequence in which they were entered.

Hope this helps.

Smokey Joe
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top