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

counting record no

Status
Not open for further replies.

channelmaster

Technical User
Dec 9, 2001
52
PH
How can you count or create a random nos.in grid. Example,
when I append a new record the no is created "1" and another appended record will be "2" and so on. I tried this code:
count to nItemno
nItemno=nItemno+1
this works alright but the problem is when you delete a record, it creates a duplicate no and not in a random manner. How do you solve this when i delete a record it would automatically recount the record and append a new number in a random way, thanks

Rene
 
you need to generate your own random number for your key field. As you have discovered the record number is not meant to be the key filed. look at faq184-259 for help in this. It is well used procedure. Attitude is Everything
 
HI CHannelMaster,

You need to do the follwoing, if you intend to continue with what you are saying above..

ASSUMED.. you have SET DELETED ON.. if not set that.

1. MyGrid.AfterRowColChangeEvent
********************************
ThisForm.mySerialCount

2. mySerialNumber && Add this method in your form.
*****************
LOCAL nRecNo, nCount, cAlias

cAlias = ALIAS()

SELECT ThisForm.MyGrid.RecordSource

IF EOF() .OR. BOF()
LOCATE
ENDIF

nRecNo = RECNO()
nCount = 1
LOCATE
IF ! EOF()
SCAN
REPLACE id_sno WITH M.nCount && the Sno field
M.nCount = M.nCount+1
ENDSCAN
GO nRecNo
ENDIF

SELECT (cAlias)

Hope this helps you :)
ramani :)
(Subramanian.G),FoxAcc, ramani_g@yahoo.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top