Bonjour,

J'aimerais que ma requête me retourne tous les noms correspondants à mon champs texte qui est le nom du client .
J'utilise la fonction like car je ne sais pas ce qui est avant et après le contenu.
Je ne sais pas ce qui ne va pas dans mon select mais aucun n'enregistrement n'est trouvé et je sais qu'il y en a.

Merci beaucoup de m'aider car j'en suis à mes débuts en VB

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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