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
|
Private Sub chkDate_Click()
If Me.chkDate Then
Me.txtRechDate.Visible = False
Else
Me.txtRechDate.Visible = True
End If
RefreshQuery
End Sub
Private Sub chkFourn_Click()
If Me.chkFourn Then
Me.cmbRechFourn.Visible = False
Else
Me.cmbRechFourn.Visible = True
End If
RefreshQuery
End Sub
Private Sub chkNum_Click()
If Me.chknum Then
Me.txtRechNum.Visible = False
Else
Me.txtRechNum.Visible = True
End If
RefreshQuery
End Sub
Private Sub cmbRechFourn_BeforeUpdate(Cancel As Integer)
RefreshQuery
End Sub
Private Sub lstResults_DblClick(Cancel As Integer)
DoCmd.OpenForm "frmAutoBon", acNormal, , "[RefBon]=" & Me.lstResults
End Sub
Private Sub txtRechDate_BeforeUpdate(Cancel As Integer)
RefreshQuery
End Sub
Private Sub txtRechNum_BeforeUpdate(Cancel As Integer)
RefreshQuery
End Sub
Private Sub RefreshQuery()
Dim SQL As String
Dim SQLWhere As String
SQL = "SELECT RefBon, NumBon, Date, Fournisseur FROM tblboncommande Where tblboncommande!RefBon <> 0 "
If Not Me.chknum Then
SQL = SQL & "And tblboncommande!NumBon = " & Me.txtRechNum
End If
If Not Me.chkDate Then
SQL = SQL & "And tblboncommande!Date = #" & Format(Me.txtRechDate, "mm/dd/yyyy") & "#"
End If
If Not Me.chkFourn Then
SQL = SQL & "And tblboncommande!Fournisseur = '" & Me.cmbRechFourn & "' "
End If
SQLWhere = Trim(Right(SQL, Len(SQL) - InStr(SQL, "Where ") - Len("Where ") + 1))
SQL = SQL & ";"
Debug.Print SQL
Debug.Print SQLWhere
Me.lblStats.Caption = DCount("*", "tblboncommande", SQLWhere) & "/" & DCount("*", "tblboncommande")
Me.lstResults.RowSource = SQL
Me.lstResults.Requery
End Sub
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 RefBon,NumBon,Date,Fournisseur FROM tblboncommande;"
Me.lstResults.Requery
End Sub |
Partager