1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102
| Option Compare Database
Private Sub Form_Load()
'Sert a effacer les champs.
Me.lstCCAbr.Value = vbNullString
Me.txtCCNor.Value = vbNullString
Me.lstAdr1.Value = vbNullString
MAJ ()
End Sub
Private Sub MAJ()
On Error Resume Next
'Les requetes.
Dim rqt, rqtCCAbr, rqtNClient, rqtPClient, rqtAdr1As String
'Toutes les valeurs selectionnés
If (Not IsNull(Me.lstCCAbr.Value) And Not Me.lstCCAbr.Value = vbNullString And Not Me.lstCCAbr.Value = "") Then
rqt = "WHERE Clients.Civclientabrg like '" + CStr(Me.lstCCAbr.Value) + "'"
Else: rqt = "WHERE Clients.Civclientabrg like '*'"
End If
If (Not IsNull(Me.lstNClient.Value) And Not Me.lstNClient.Value = vbNullString And Not Me.lstNClient.Value = "") Then
rqt = rqt + " AND Clients.Nomclient like '" + CStr(Me.lstNClient.Value) + "'"
End If
If (Not IsNull(Me.lstPClient.Value) And Not Me.lstPClient.Value = vbNullString And Not Me.lstPClient.Value = "") Then
rqt = rqt + " AND Clients.Prenomclient like '" + CStr(Me.lstPClient.Value) + "'"
End If
If (Not IsNull(Me.lstAdr1.Value) And Not Me.lstAdr1.Value = vbNullString And Not Me.lstAdr1.Value = "") Then
rqt = rqt + " AND Clients.Adresse1 like '" + CStr(Me.lstAdr1.Value) + "'"
End If
'Requete sur la civilite abregee du client
rqtCCAbr = "SELECT DISTINCT Civclientabrg FROM Clients " + rqt
rqtCCAbr = rqtCCAbr + " ORDER BY Clients.Civclientabrg;"
RequeteNClient:
'Requete sur le nom du client
rqtNClient = "SELECT DISTINCT Nomclient FROM Clients " + rqt
rqtNClient = rqtNClient + " ORDER BY Clients.Nomclient;"
Me.lstNClient.RowSource = rqtNClient
Me.lstNClient.Requery
If (Me.lstNClient.ListCount = 1) Then
Me.lstNClient.Selected(0) = True
If Me.lstNClient.ListIndex = -1 Then
Me.lstNClient.ListIndex = 0
End If
End If
RequetePClient:
'Requete sur le prenom du client
rqtPClient = "SELECT DISTINCT Prenomclient FROM Clients " + rqt
rqtPClient = rqtPClient + " ORDER BY Clients.Prenomclient;"
Me.lstPClient.RowSource = rqtPClient
Me.lstPClient.Requery
If (Me.lstPClient.ListCount = 1) Then
Me.lstPClient.Selected(0) = True
If Me.lstPClient.ListIndex = -1 Then
Me.lstPClient.ListIndex = 0
End If
End If
RequeteAdr1:
'Requete sur l'adresse 1 du client
rqtAdr1 = "SELECT DISTINCT Adresse1 FROM Clients " + rqt
rqtAdr1 = rqtAdr1 + " ORDER BY Clients.Adresse1;"
Me.lstAdr1.RowSource = rqtAdr1
Me.lstAdr1.Requery
If (Me.lstAdr1.ListCount = 1) Then
Me.lstAdr1.Selected(0) = True
If Me.lstAdr1.ListIndex = -1 Then
Me.lstAdr1.ListIndex = 0
End If
End If
End Sub
Private Sub lstCCAbr_AfterUpdate()
MAJ ()
End Sub
Private Sub lstNClient_AfterUpdate()
MAJ ()
End Sub
Private Sub lstPClient_AfterUpdate()
MAJ ()
End Sub
Private Sub lstAdr1_AfterUpdate()
MAJ ()
End Sub |
Partager