Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Displaying Recordset in DataGrid
Message
From
02/08/2000 09:34:57
 
General information
Forum:
Visual Basic
Category:
Other
Miscellaneous
Thread ID:
00399667
Message ID:
00399812
Views:
15
For the total, you have, at least, 2 choices
First: You can write a bucle that reads cells in the column corresponding to the field that you want sum. It´s some like this:

dim i
dim sum
DataGrid1.Col = ? '?=Index of column you want sum
for i = 0 to 20
DataGrid1.Row = i
sum = sum + Val(DataGrid1.Text)
next i
Print sum

Second: DataGrid updates DataSource automatic, then you can use Sum in a SQL expression through ADO. By example:

dim con as Connection
dim rs as Recordset
dim sql as String
sql = "SELECT Sum(YourField) AS SumYourField FROM YourTable"
con.Open "YourConnectionString or YourDSN"
set rs = con.Execute(sql)
Print rs("SumYourField")


I hope you are satisfied.


glurrea
glurrea
Previous
Reply
Map
View

Click here to load this message in the networking platform