Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Displaying Recordset in DataGrid
Message
De
02/08/2000 09:34:57
 
Information générale
Forum:
Visual Basic
Catégorie:
Autre
Divers
Thread ID:
00399667
Message ID:
00399812
Vues:
14
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
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform