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
| Private Sub RefreshQuery()
Dim SQL As String
Dim SQLWhere As String
SQL = "SELECT Materials.IDMaterial, Materials.MaterialType, Materials.MaterialName, Materials.HeatTreatment, Materials.PreTreatment, Materials.PreTreatmentSupplier, Materials.FabricationProcess, Materials.YoungModulus, Materials.UltimateTensileStress, Materials.Elongation, Materials.PoissonRatio, Materials.Density, Materials.Specification, Materials.LastUpdated, Suppliers.IDSupplier, Suppliers.SupplierName, Suppliers.Postcode, Suppliers.Adress, Suppliers.Town, Suppliers.Country, Suppliers.WebSite, Suppliers.Contact, Suppliers.[E-mail], Suppliers.Telephone, Suppliers.Fax, Suppliers.LastUpdated FROM Suppliers INNER JOIN Materials ON Suppliers.IDSupplier = Materials.IDSupplier Where Materials!IDMaterial <> 0 "
If Me.chkIDMaterial Then
SQL = SQL & "and Materials!IDMaterial = " & Me.txtIDMaterial & " "
End If
If Me.chkMaterialType Then
SQL = SQL & "and Materials!MaterialType = '" & Me.cmbMaterialType & "' "
End If
If Me.chkMaterialName Then
SQL = SQL & "and Materials!MaterialName like '*" & Me.txtMaterialName & "*' "
End If
If Me.chkHeatTreatment Then
SQL = SQL & "and Materials!HeatTreatment = '" & Me.cmbHeatTreatment & "' "
End If
If Me.chkPreTreatment Then
SQL = SQL & "and Materials!PreTreatment = '" & Me.cmbPreTreatment & "' "
End If
If Me.chkPreTreatmentSupplier Then
SQL = SQL & "and Materials!PreTreatmentSupplier = '" & Me.cmbPreTreatmentSupplier & "' "
End If
If Me.chkFabricationProcess Then
SQL = SQL & "and Materials!FabricationProcess = '" & Me.cmbFabricationProcess & "' "
End If
If Me.chkIDSupplier Then
SQL = SQL & "And Suppliers!IDSupplier = " & Me.txtIDSupplier & " "
End If
If Me.chkSupplierName Then
SQL = SQL & "And Suppliers!SupplierName like '*" & Me.txtSupplierName & "*' "
End If
If Me.chkTown Then
SQL = SQL & "And Suppliers!Town like '*" & Me.txtTown & "*' "
End If
If Me.chkCountry Then
SQL = SQL & "And Suppliers!Country = '" & Me.cmbCountry & "' "
End If
If Me.chkContact Then
SQL = SQL & "And Suppliers!Contact like '*" & Me.txtContact & "*' "
End If
SQLWhere = Trim(Right(SQL, Len(SQL) - InStr(SQL, "Where ") - Len("Where ") + 1))
SQL = SQL & ";"
Me.lblStats.Caption = DCount("*", "Materials", SQLWhere) & " / " & DCount("*", "Materials")
Me.lstResults.RowSource = SQL
Me.lstResults.Requery |
Partager