Private Sub Report_Proc()
On Error GoTo err_Report_Proc
Dim cn As New ADODB.Connection
Dim cmd As New ADODB.Command
cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & App.Path & "\Internet Record.mdb;Jet OLEDB:Database Password=jaypee;"
Select Case cboCategory.ListIndex
Case 0
[font=Verdana]strQuery =[/font] "Format([DateTimeLogin], 'm/d/yyyy') = #" & BegDate & "#"
strQuery = "SELECT * From [Login History Query] Where " & strQuery
Case 1, 2
strQuery = "Format([DateTimeLogin], 'm/d/yyyy') Between #" & BegDate & "# And #" & EndDate & "#"
strQuery = "SELECT * FROM [Login History Query] Where " & strQuery
Case 3
strQuery = "Format([DateTimeLogin],'yyyy') = " & BegDate & ""
strQuery = "SELECT * FROM [Login History Query] Where " & strQuery
End Select
With cmd
.ActiveConnection = cn
.CommandType = adCmdText
'.CommandText = "Select usercode, name, datetimelogin, datetimelogout, amount from [login history query]"
.CommandText = strQuery
.Execute
End With
With rstReport
.ActiveConnection = cn
.CursorLocation = adUseClient
.Open cmd
End With
Exit Sub
err_Report_Proc:
lblStatus = Err.Number & "-" & Err.Description & " Report_Proc procedure call"
End Sub