Need help...
Table Name - cashbook Field name - pname & amount
Examble
pname amount Antony 1500 Jose 3000 Antony 3500
need to display in msflexgrid like belo
Antony - 5000 Jose - 3000
below my code is not working....can anybody help me
Rec.open "select from pname,sum(amount) as amt from cashbook group by pname order by pname,var,adopendynamic,adlockoptimist"
While rec.eof=false
Pymnt.rows=pymnt.rows+1
Pymnt.textmatrix(pymnt.rows -1,0)=rec!pname
Pymnt.textmatrix(pymnt.rows -1,1)=amt
Rec.movenext
Wend
Rec.close
I made a few fixes to your code and came up with the following:
Public Sub Test()
rec.Open "select pname, sum(amount) as amt from cashbook group by pname order by pname", var, adOpenDynamic, adLockOptimistic
While Not rec.EOF
pymnt.Rows = pymnt.Rows + 1
pymnt.textmatrix(pymnt.Rows - 1, 0) = rec.Fields("pname").Value
pymnt.textmatrix(pymnt.Rows - 1, 1) = rec.Fields("amt").Value
rec.MoveNext
Wend
rec.Close
End Sub
The fixes I made include:
Open
methodvar
is an open Connection
objectadLockOptimistic
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.