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
| Private Sub Form_Load()
Dim ctl As Control
For Each ctl In Me.Controls
Select Case Left(ctl.Name, 3)
Case "chk"
ctl.Value = -1
Case "lbl"
ctl.Caption = "- * - * -"
Case "txt"
ctl.Visible = False
ctl.Value = ""
Case "cmb"
ctl.Visible = False
End Select
Next ctl
Me.lstResults.RowSource = "SELECT ID, Supplier, Type, Country, Province, Turnover, Export, Status, Impression FROM Base Where ( Category = 'Sport'Or Category2 = 'Sport' Or Category3 = 'Sport' ) Order by Base.Supplier ;"
Me.lstResults.Requery
End Sub
Private Sub RefreshQuery()
Dim SQL As String
Dim SQLWhere As String
SQL = "SELECT ID, Supplier, Type, Country, Province, Turnover, Export, Status, Impression FROM Base Where Base!ID <> 0 And ( Category = 'Sport' Or Category2 = 'Sport' Or Category3 = 'Sport' ) ORDER BY Base.Supplier "
If Not Me.chkSupplier Then
SQL = "SELECT ID, Supplier, Type, Country, Province, Turnover, Export, Status, Impression FROM Base Where Base!ID <> 0 And ( Category = 'Sport' Or Category2 = 'Sport' Or Category3 = 'Sport' ) And Base!Supplier like '*" & Me.txtRechSupplier & "*' ORDER By Base.Supplier "
End If
If Not Me.chkCountry Then
SQL = "SELECT ID, Supplier, Type, Country, Province, Turnover, Export, Status, Impression FROM Base Where Base!ID <> 0 And ( Category = 'Sport' Or Category2 = 'Sport' Or Category3 = 'Sport' ) And Base!Country = '" & Me.cmbRechCountry & "' ORDER BY Base.Supplier "
End If
If Not Me.chkType Then
SQL = "SELECT ID, Supplier, Type, Country, Province, Turnover, Export, Status, Impression FROM Base Where Base!ID <> 0 And ( Category = 'Sport' Or Category2 = 'Sport' Or Category3 = 'Sport' ) And Base!Type = '" & Me.cmbRechType & "' ORDER BY Base.Supplier "
End If
If Not Me.chkProvince Then
SQL = "SELECT ID, Supplier, Type, Country, Province, Turnover, Export, Status, Impression FROM Base Where Base!ID <> 0 And ( Category = 'Sport' Or Category2 = 'Sport' Or Category3 = 'Sport' ) And Base!Province = '" & Me.cmbRechProvince & "' ORDER BY Base.Supplier "
End If
If Not Me.chkTurnover Then
SQL = "SELECT ID, Supplier, Type, Country, Province, Turnover, Export, Status, Impression FROM Base Where Base!ID <> 0 And ( Category = 'Sport' Or Category2 = 'Sport' Or Category3 = 'Sport' ) And Base!Turnover = '" & Me.cmbRechTurnover & "' ORDER BY Base.Supplier "
End If
If Not Me.chkExport Then
SQL = "SELECT ID, Supplier, Type, Country, Province, Turnover, Export, Status, Impression FROM Base Where Base!ID <> 0 And ( Category = 'Sport' Or Category2 = 'Sport' Or Category3 = 'Sport' ) And Base!Export = '" & Me.cmbRechExport & "' ORDER BY Base.Supplier "
End If
If Not Me.chkStatus Then
SQL = "SELECT ID, Supplier, Type, Country, Province, Turnover, Export, Status, Impression FROM Base Where Base!ID <> 0 And ( Category = 'Sport' Or Category2 = 'Sport' Or Category3 = 'Sport' ) And Base!Status = '" & Me.cmbRechStatus & "' ORDER BY Base.Supplier "
End If
If Not Me.chkImpression Then
SQL = "SELECT ID, Supplier, Type, Country, Province, Turnover, Export, Status, Impression FROM Base Where Base!ID <> 0 And ( Category = 'Sport' Or Category2 = 'Sport' Or Category3 = 'Sport' ) And Base!Impression = '" & Me.cmbRechImpression & "' ORDER BY Base.Supplier "
End If
SQLWhere = Trim(Right(SQL, Len(SQL) - InStr(SQL, "Where ") - Len("Where ") + 1))
SQL = SQL & ";"
Me.lblStats.Caption = DCount("*", "Base", SQLWhere) & " / " & DCount("*", "Base")
Me.lstResults.RowSource = SQL
Me.lstResults.Requery
End Sub |
Partager