now i need is select that specify month and show that sum of total_hr.
eg:
working_date total_hr total_ot_hr
20/2/2007 5 10
21/2/2007 5 10
22/2/2007 5 10
23/2/2007 5 10
23/3/2007 5 10
if i select febuary it will :
retrieve sum of total_hr = 20
retrieve sum of total_ot_hr = 40
pls help me.
thanks !
eg:
working_date total_hr total_ot_hr
20/2/2007 5 10
21/2/2007 5 10
22/2/2007 5 10
23/2/2007 5 10
23/3/2007 5 10
if i select febuary it will :
retrieve sum of total_hr = 20
retrieve sum of total_ot_hr = 40
pls help me.
thanks !
Code:
Dim cn3 As New ADODB.Connection
Dim strCNString3 As String
Dim rs3 As New ADODB.Recordset
Dim intFound3 As Double
strCNString3 = "Data Source=" & App.Path & "\PayrollBakeryDB.mdb"
cn3.Provider = "Microsoft Jet 4.0 OLE DB Provider"
cn3.ConnectionString = strCNString3
cn3.Open
Dim intMonth As Integer
If cboMonth.ListIndex = 0 Then
intMonth = 0
ElseIf cboMonth.ListIndex = 1 Then
intMonth = 1
ElseIf cboMonth.ListIndex = 2 Then
intMonth = 2
ElseIf cboMonth.ListIndex = 3 Then
intMonth = 3
ElseIf cboMonth.ListIndex = 4 Then
intMonth = 4
ElseIf cboMonth.ListIndex = 5 Then
intMonth = 5
ElseIf cboMonth.ListIndex = 6 Then
intMonth = 6
ElseIf cboMonth.ListIndex = 7 Then
intMonth = 7
ElseIf cboMonth.ListIndex = 8 Then
intMonth = 8
ElseIf cboMonth.ListIndex = 9 Then
intMonth = 9
ElseIf cboMonth.ListIndex = 10 Then
intMonth = 10
ElseIf cboMonth.ListIndex = 11 Then
intMonth = 11
End If
With rs3
.Open "SELECT working_date, Sum(total_hr), Sum(total_ot_hr) FROM clock GROUP BY working_date", cn3, adOpenDynamic, adLockOptimistic
Do Until .EOF
If Month(!working_date) = intMonth Then 'why this not effect
txtWorkedHr.Text = !total_hr 'here is i wan the total of sum
txtWorkedOtHr.Text = !total_ot_hr 'here is i wan the total of sum
intFound3 = 1
End If
.MoveNext
Loop
End With
Comment