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 103 104 105 106 107 108
|
Private Sub Btn_Recherche_Click()
Dim strField As String
Dim strCriteria As String
Dim strCriteria2 As String
Dim strCriteria3 As String
Dim strCriteria4 As String
Dim strSql As String
Dim strSql2 As String
Dim strSql3 As String
Dim strSql4 As String
strCriteria = ""
strCriteria2 = ""
strCriteria3 = ""
strCriteria4 = ""
' compose le critere de recherche
If Not IsNull(Me.cbo_Type.Value) And Me.cbo_Type.Value <> "" Then
strCriteria = " WHERE BDD.Type Like " & Chr(34) & cbo_Type.Value & Chr(34)
If Not IsNull(Me.cbo_Reference.Value) And Me.cbo_Reference.Value <> "" Then
strCriteria = strCriteria & " AND BDD.Reference Like " & Chr(34) & Me.cbo_Reference.Value & Chr(34)
End If
Else
If Not IsNull(Me.cbo_Reference.Value) And Me.cbo_Reference.Value <> "" Then
strCriteria = " WHERE BDD.Reference Like " & Chr(34) & Me.cbo_Reference.Value & Chr(34)
End If
End If
If Not IsNull(Me.cbo_Reference.Value) And Me.cbo_Reference.Value <> "" Then
strCriteria = " WHERE BDD.Reference Like " & Chr(34) & cbo_Reference.Value & Chr(34)
If Not IsNull(Me.cbo_Fabricant.Value) And Me.cbo_Fabricant.Value <> "" Then
strCriteria = strCriteria & " AND BDD.Fabricant Like " & Chr(34) & Me.cbo_Fabricant.Value & Chr(34)
End If
Else
If Not IsNull(Me.cbo_Fabricant.Value) And Me.cbo_Fabricant.Value <> "" Then
strCriteria = " WHERE BDD.Fabricant Like " & Chr(34) & Me.cbo_Fabricant.Value & Chr(34)
End If
End If
' construit la requête sql
strSql = "SELECT DISTINCTROW BDD.*"
strSql = strSql & " FROM BDD "
If strCriteria <> "" Then
strSql = strSql & strCriteria
End If
strSql2 = "SELECT DISTINCTROW BDD.Reference, BDD.Fabricant, BDD.[Type de contact], BDD.Pince, BDD.Locator"
strSql2 = strSql2 & " FROM BDD "
If strCriteria Like "*Contact*" Then
Me.Resultat.ColumnCount = 5
Me.Resultat.Width = 8500
Me.Resultat.Left = 4200
Me.Resultat.ColumnWidths = "3cm;2cm;4cm;3cm;3cm"
strSql = strSql2 & strCriteria
End If
strSql3 = "SELECT DISTINCTROW BDD.Reference, BDD.Fabricant, BDD.Taille, BDD.[Type de raccord]"
strSql3 = strSql3 & " FROM BDD "
If strCriteria Like "*Raccord*" Then
Me.Resultat.ColumnCount = 4
Me.Resultat.Width = 8000
Me.Resultat.Left = 4300
Me.Resultat.ColumnWidths = "3cm;2cm;2cm;4cm"
strSql = strSql3 & strCriteria
End If
strSql4 = "SELECT DISTINCTROW BDD.Reference, BDD.Fabricant, BDD.Taille, BDD.Contacts, BDD.[Type de contact], BDD.Pince, BDD.Locator"
strSql4 = strSql4 & " FROM BDD"
If strCriteria Like "*Connecteur*" Then
Me.Resultat.ColumnCount = 7
Me.Resultat.Width = 12000
Me.Resultat.Left = 2200
Me.Resultat.ColumnWidths = "3cm;2cm;2cm;4cm;4cm;3cm;3cm"
strSql = strSql4 & strCriteria
End If
'Debug.Print strSql
Me.Resultat.RowSource = strSql ' affecte sql au tableau
End Sub
Private Sub cbo_Fabricant_Change()
Me.cbo_Type.RowSource = " SELECT DISTINCT BDD.Type FROM BDD WHERE BDD.Fabricant = " & Chr(34) & cbo_Fabricant.Value & Chr(34)
Me.cbo_Reference.RowSource = " SELECT DISTINCT BDD.Reference FROM BDD WHERE BDD.Fabricant = " & Chr(34) & cbo_Fabricant.Value & Chr(34)
End Sub
Private Sub cbo_Reference_Change()
Me.cbo_Type.RowSource = " SELECT DISTINCT BDD.Type FROM BDD WHERE BDD.Reference = " & Chr(34) & cbo_Reference.Value & Chr(34)
Me.cbo_Fabricant.RowSource = " SELECT DISTINCT BDD.Fabricant FROM BDD WHERE BDD.Reference = " & Chr(34) & cbo_Reference.Value & Chr(34)
End Sub
Private Sub cbo_Type_Change()
Me.cbo_Reference.RowSource = " SELECT DISTINCT BDD.Reference FROM BDD WHERE BDD.Type = " & Chr(34) & cbo_Type.Value & Chr(34)
Me.cbo_Fabricant.RowSource = " SELECT DISTINCT BDD.Fabricant FROM BDD WHERE BDD.Type = " & Chr(34) & cbo_Type.Value & Chr(34)
End Sub
Private Sub RAZ_Click()
DoCmd.Close acForm, "Recherche", acSaveNo
DoCmd.OpenForm "Recherche"
End Sub |
Partager