Code: Select all
Set RST0 = New ADODB.Recordset
With RST0
.CursorType = adOpenKeyset
' .CursorLocation = adUseClient '
.LockType = adLockOptimistic
End With
Set CMD = New ADODB.Command
With CMD
.CommandTimeout = 0
.CommandText = SQL
.ActiveConnection = CONN
.CommandType = adCmdText
.Prepared = True
DoEvents
Set RST0 = .Execute
Set CMD = Nothing
End With
Code: Select all
Set CONN = New ADODB.Connection
With CONN
.CommandTimeout = 1000
.ConnectionTimeout = 1000
.CursorLocation = adUseServer
.Open "Provider=Microsoft.Jet.OLEDB.4.0; " & _
"Data Source=C:\REPORT_L0928\L0928_TEST.mdb;"
End With
If Not Me.SPORT3.Text = "TUTTI" Then
SQL = "SELECT L0928_SI.COD, CODICI.DESCR_COD, COUNT(L0928_SI.COD) AS CONTA FROM L0928_SI INNER JOIN CODICI ON L0928_SI.COD = CODICI.COD WHERE L0928_SI.DATA_ESECUZIONE BETWEEN #" & Format(Me.DATE4.Text, "MM/DD/YYYY") & "# AND #" & Format(Me.DATE5.Text, "MM/DD/YYYY") & "# AND L0928_SI.SPORT='" & Me.SPORT3.Text & "' GROUP BY L0928_SI.COD, CODICI.DESCR_COD ORDER BY L0928_SI.COD, COUNT(L0928_SI.COD)"
Else
SQL = "SELECT L0928_SI.COD, CODICI.DESCR_COD, COUNT(L0928_SI.COD) AS CONTA FROM L0928_SI INNER JOIN CODICI ON L0928_SI.COD = CODICI.COD WHERE L0928_SI.DATA_ESECUZIONE BETWEEN #" & Format(Me.DATE4.Text, "MM/DD/YYYY") & "# AND #" & Format(Me.DATE5.Text, "MM/DD/YYYY") & "# GROUP BY L0928_SI.COD, CODICI.DESCR_COD ORDER BY L0928_SI.COD, COUNT(L0928_SI.COD)"
End If
in this case Me.SPORT3.Text = "TUTTI"
note:
All fields with where clausole are indexed in table are indexed