1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| Dim oCnx As New ADODB.Connection
oCnx.Open "Provider=SQLOLEDB;Server=mecinov;uid=Production;pwd=Production;database=commandes"
Dim DBCommandesSQL As New ADODB.Recordset
strfiltre = ""
If Me.TxtClient <> "" And Not IsNull(Me.TxtClient) Then
strfiltre = "nomcli like '*" & Replace(Me.TxtClient, "'", "''") & "*'"
End If
If Me.TxtDateFrom <> "" And Not IsNull(Me.TxtDateFrom) Then
If strfiltre <> "" Then
strfiltre = strfiltre & " AND "
End If
strfiltre = strfiltre & "date01 between '" + Format(Me.TxtDateFrom, "yyyy/mm/dd") + "' and '" + Format(Me.txtDateTo, "yyyy/mm/dd") + "'"
End If
If strfiltre <> "" Then
strfiltre = "WHERE " & strfiltre
End If
DBCommandesSQL.Open "SELECT * FROM status " & strfiltre, oCnx, adOpenStatic, adLockReadOnly
If DBCommandesSQL.EOF Then
MsgBox ("Aucun résultat disponible pour votre sélection")
End If |