Bonjour ,

J’applique aujourd’hui la recherche multi critères (decrite par Cafeine) sur une requête nommée "Query1" (plutôt complexe) et je rencontre plusieurs difficultés. Je vous en remercie d’avance. Mon projet touche a sa fin. Il me reste plus que cette fameuse recherche multi critères et multi table a effectuer !! Je m’explique : Prenons ma table « Adhesive Tests » (je voudrais vous postez egalement mon Access de 1.5Mo mais je n'y arrive pas, taille maxi de la piece jointe de 0.5Mo... je vous mets donc un extrait de mon code).
Un test adhésif étant constitué de :
• 1 « supplier »
• 1 « adhesive avec son supplier »
• 1 « material avec son supplier »
• 1 autre « material avec son supplier »
Maintenant mon objectif est d’arriver à rechercher un « Adhesive Test » a partir de son supplier par exemple. Le problème est que si l’on regarde dans le code que je vous ai fourni, il est impossible de faire la distinction entre : « Adhesive Test Supplier », « Adhesive Supplier », « Material 1 Supplier » et « Material 2 Supplier » car tous ces « suppliers » sont recherchés dans la même table « Suppliers »… (Vous me suivez ?)
Voila donc ma première difficulté : Faire la différence entre tous ces « suppliers », sachant qu’ils sont tous recherchés dans la même table. Pour résoudre ce problème j’ai pensé à effectuer ma recherche directement sur ma requête « Query1 » mais je n’y arrive pas non plus ».

Mon 2eme problème est plus simple à expliquer. Lorsque je lance une recherche a partir du champ "MaterialType" par exemple, j’obtiens l'erreur suivante:
Run-time error ‘3079’ : The specified field ‘Materials!MaterialType' could refer to more than one table listed in the FROM clause of your statement.
Je pense que ce n’ait pas anodin et que ces 2 problèmes sont liés…
Quelqu’un serait il comment reprendre tout ça ?

MERCI
Cosmo

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
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
Private Sub RefreshQuery()
Dim SQL As String
Dim SQLWhere As String
 
 
SQL = "SELECT * FROM Query1 Where AdhesiveTests.IDAdhesiveTest <> 0 "
 
'Pour une recherche a partir d'infos sur le "test adhesif"
If Me.chkAdhesiveTestID Then
    SQL = SQL & "and AdhesiveTests!IDAdhesiveTest = " & Me.txtAdhesiveTestID & " "
End If
If Me.chkTestName Then
    SQL = SQL & "and AdhesiveTests!TestName = '*" & Me.cmbTestName & "*' "
End If
If Me.chkSpecification Then
    SQL = SQL & "and AdhesiveTests!Specification like '*" & Me.TxtSpecification & "*' "
End If
 
'Pour une recherche a partir d'infos sur l'"adhesive test supplier"
If Me.chkAdhesiveTestSupplierSupplierID Then
    SQL = SQL & "And Suppliers!IDSupplier = " & Me.txtAdhesiveTestSupplierSupplierID & " "
End If
If Me.chkAdhesiveTestSupplierSupplierName Then
    SQL = SQL & "And Suppliers!SupplierName = '" & Me.cmbAdhesiveTestSupplierSupplierName & "' "
End If
If Me.chkAdhesiveTestSupplierTown Then
    SQL = SQL & "And Suppliers!Town like '*" & Me.txtAdhesiveTestSupplierTown & "*' "
End If
If Me.chkAdhesiveTestSupplierCountry Then
    SQL = SQL & "And Suppliers!Country = '" & Me.cmbAdhesiveTestSupplierCountry & "' "
End If
If Me.chkAdhesiveTestSupplierContact Then
    SQL = SQL & "And Suppliers!Contact like '*" & Me.txtAdhesiveTestSupplierContact & "*' "
End If
 
 
'Pour une recherche a partir d'infos sur l'"adhesif"
If Me.chkAdhesiveID Then
    SQL = SQL & "and Adhesives!IDAdhesive = " & Me.txtAdhesiveID & " "
End If
If Me.chkAdhesiveType Then
    SQL = SQL & "and Adhesives!AdhesiveType = '" & Me.cmbAdhesiveType & "' "
End If
If Me.chk1Kor2K Then
    SQL = SQL & "and Adhesives!1Kor2K = '" & Me.cmb1Kor2K & "' "
End If
If Me.chkAdhesiveName Then
    SQL = SQL & "and Adhesives!AdhesiveName like '*" & Me.txtAdhesiveName & "*' "
End If
 
 
'Pour une recherche a partir d'infos sur l'"adhesive supplier"
If Me.chkAdhesiveSupplierSupplierID Then
    SQL = SQL & "And Suppliers!IDSupplier = " & Me.txtAdhesiveSupplierSupplierID & " "
End If
If Me.chkAdhesiveSupplierSupplierName Then
    SQL = SQL & "And Suppliers!SupplierName = '" & Me.cmbAdhesiveSupplierSupplierName & "' "
End If
If Me.chkAdhesiveSupplierTown Then
    SQL = SQL & "And Suppliers!Town like '*" & Me.txtAdhesiveSupplierTown & "*' "
End If
If Me.chkAdhesiveSupplierCountry Then
    SQL = SQL & "And Suppliers!Country = '" & Me.cmbAdhesiveSupplierCountry & "' "
End If
If Me.chkAdhesiveSupplierContact Then
    SQL = SQL & "And Suppliers!Contact like '*" & Me.txtAdhesiveSupplierContact & "*' "
End If
 
 
'Pour une recherche a partir d'infos sur le "material substrate 1"
If Me.chkMaterialM1ID Then
    SQL = SQL & "and Materials!IDMaterial = " & Me.txtMaterialM1ID & " "
End If
If Me.chkMaterialTypeM1 Then
    SQL = SQL & "and Materials!MaterialType = '" & Me.cmbMaterialTypeM1 & "' "
End If
If Me.chkMaterialNameM1 Then
    SQL = SQL & "and Materials!MaterialName like '*" & Me.txtMaterialNameM1 & "*' "
End If
If Me.chkHeatTreatmentM1 Then
    SQL = SQL & "and Materials!HeatTreatment = '" & Me.cmbHeatTreatmentM1 & "' "
End If
If Me.chkPreTreatmentM1 Then
    SQL = SQL & "and Materials!PreTreatment = '" & Me.cmbPreTreatmentM1 & "' "
End If
If Me.chkPreTreatmentSupplierM1 Then
    SQL = SQL & "and Materials!PreTreatmentSupplier = '" & Me.cmbPreTreatmentSupplierM1 & "' "
End If
If Me.chkFabricationProcessM1 Then
    SQL = SQL & "and Materials!FabricationProcess = '" & Me.cmbFabricationProcessM1 & "' "
End If
 
'Pour une recherche a partir d'infos sur le "material 1 supplier"
If Me.chkMaterial1SupplierSupplierID Then
    SQL = SQL & "And Suppliers!IDSupplier = " & Me.txtMaterial1SupplierSupplierID & " "
End If
If Me.chkMaterial1SupplierSupplierName Then
    SQL = SQL & "And Suppliers!SupplierName = '" & Me.cmbMaterial1SupplierSupplierName & "' "
End If
If Me.chkMaterial1SupplierTown Then
    SQL = SQL & "And Suppliers!Town like '*" & Me.txtMaterial1SupplierTown & "*' "
End If
If Me.chkMaterial1SupplierCountry Then
    SQL = SQL & "And Suppliers!Country = '" & Me.cmbMaterial1SupplierCountry & "' "
End If
If Me.chkMaterial1SupplierContact Then
    SQL = SQL & "And Suppliers!Contact like '*" & Me.txtMaterial1SupplierContact & "*' "
End If
 
'Pour une recherche a partir d'infos sur le "material substrate 2"
If Me.chkMaterialM2ID Then
    SQL = SQL & "and Materials!IDMaterial = " & Me.txtMaterialM2ID & " "
End If
If Me.chkMaterialTypeM2 Then
    SQL = SQL & "and Materials!MaterialType = '" & Me.cmbMaterialTypeM2 & "' "
End If
If Me.chkMaterialNameM2 Then
    SQL = SQL & "and Materials!MaterialName like '*" & Me.txtMaterialNameM2 & "*' "
End If
If Me.chkHeatTreatmentM2 Then
    SQL = SQL & "and Materials!HeatTreatment = '" & Me.cmbHeatTreatmentM2 & "' "
End If
If Me.chkPreTreatmentM2 Then
    SQL = SQL & "and Materials!PreTreatment = '" & Me.cmbPreTreatmentM2 & "' "
End If
If Me.chkPreTreatmentSupplierM2 Then
    SQL = SQL & "and Materials!PreTreatmentSupplier = '" & Me.cmbPreTreatmentSupplierM2 & "' "
End If
If Me.chkFabricationProcessM2 Then
    SQL = SQL & "and Materials!FabricationProcess = '" & Me.cmbFabricationProcessM2 & "' "
End If
 
'Pour une recherche a partir d'infos sur le "material 2 supplier"
If Me.chkMaterial2SupplierSupplierID Then
    SQL = SQL & "And Suppliers!IDSupplier = " & Me.txtMaterial2SupplierSupplierID & " "
End If
If Me.chkMaterial2SupplierSupplierName Then
    SQL = SQL & "And Suppliers!SupplierName = '" & Me.cmbMaterial2SupplierSupplierName & "' "
End If
If Me.chkMaterial2SupplierTown Then
    SQL = SQL & "And Suppliers!Town like '*" & Me.txtMaterial2SupplierTown & "*' "
End If
If Me.chkMaterial2SupplierCountry Then
    SQL = SQL & "And Suppliers!Country = '" & Me.cmbMaterial2SupplierCountry & "' "
End If
If Me.chkMaterial2SupplierContact Then
    SQL = SQL & "And Suppliers!Contact like '*" & Me.txtMaterial2SupplierContact & "*' "
End If
 
 
SQLWhere = Trim(Right(SQL, Len(SQL) - InStr(SQL, "Where ") - Len("Where ") + 1))
 
SQL = SQL & ";"
 
Me.lblStats.Caption = DCount("*", "Query1", SQLWhere) & " / " & DCount("*", "Query1")
Me.lstResults.RowSource = SQL
Me.lstResults.Requery
 
End Sub