Use a for loop to get every field value and add it to a counter total -
Dim xRecords As Integer, xTotal As Integer ''Assuming that you are trying to get a number total!!
xTotal = 0
For xRecords = 0 To rs.RecordCount - 1 ''Or however many records were returned...
''Also assuming that your record selector is called rs...
xTotal = xTotal + rs!TheFieldNameHere
rs.MoveNext
Next xRecords
lTotal.Caption = xTotal
AndreRet
Industrious Poster
4,706 posts since Jan 2008
Reputation Points: 391
Solved Threads: 481
Skill Endorsements: 20
Show me the code you are using to show the label captions when clicking on listview.
The code will go in there. Paste it here and I will add my part.
AndreRet
Industrious Poster
4,706 posts since Jan 2008
Reputation Points: 391
Solved Threads: 481
Skill Endorsements: 20
You will do something like this -
Private Sub cmdSearch.Click()
Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset
Set cn = New ADODB.Connection
cn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\data.mdb;Persist Security Info=False"
''make sure it is in your folder where your app is saved!!
cn.Open
Set rs = New ADODB.Recordset
rs.Open ("SELECT * FROM attendance WHERE absent => '0'), con, adOpenDynamic, adLockOptimistic
If rs.EOF = True Or rs.BOF = True Then
MsgBox "No record found"
Exit Sub
Else
Set ListView1.Datasource = rs
Dim xRecords As Integer, xTotal As Integer ''Assuming that you are trying to get a number total!!
xTotal = 0
For xRecords = 0 To rs.RecordCount - 1 ''Or however many records were returned...
''Also assuming that your record selector is called rs...
xTotal = xTotal + rs!absent
rs.MoveNext
Next xRecords
lTotal.Caption = xTotal
End Sub
AndreRet
Industrious Poster
4,706 posts since Jan 2008
Reputation Points: 391
Solved Threads: 481
Skill Endorsements: 20
Question Answered as of 3 Months Ago by
AndreRet Only a pleasure. Happy coding.
AndreRet
Industrious Poster
4,706 posts since Jan 2008
Reputation Points: 391
Solved Threads: 481
Skill Endorsements: 20