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!

datagrid counting rows problem

Status
Not open for further replies.

kirpowski

Programmer
Oct 18, 2003
5
TR
hi guys,
i am new in tek-teps and need your help. I have a form with datagrid on it. and I want to use the first Column of the dtagrid as a Counter which shows the row number(SiraNo is thename of the column). I have written this code (below), under the command (in dataenvironment) but it is not counting, isntead of counting it puts 1 to all of the rows...but it should go like 1..2..3..
if anyone can help i really appreciate.

thanks,
kirpowki


SELECT COUNT(*) AS SiraNo, KayitNo AS KNo, Birim,
Bolum AS Bölüm, KasaMarka AS KMarka, CPU,
SorumluP AS KullaniciP, SenetAlan AS SenediAlanP
FROM tblPC
GROUP BY KayitNo, Birim, Bolum, KasaMarka, CPU, SorumluP,
SenetAlan
ORDER BY KayitNo
 
You need to do something like this
Dim Countervariable as long
Create & OPen a dynaset recordset MyRec on the table data(many examples in the Help CD)
With MyRec
.Movefirst
do until MyRec.EOF
.Edit
CounterVariable=CounterVariable+1
.Fields(0).value=CounterVariable
.Update
.MoveNext
Loop
.Close

Every time you run this it will put a new sequence to the records depending on how you have the SORT Criteria for the recordset (if any).
EG. If you want the numbers to be in Name order you include "SORT by Name"
 
hi tedsmith,
thank you for your help. It really worked great!!!:)

thanx again
kirp

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top