Solved Base on Two Date want to Filtering others Combo box (1 Viewer)

smtazulislam

Member
Local time
Today, 22:42
Joined
Mar 27, 2020
Messages
806
Hello
Can anyone check why my date field is not work.
I would like to enter the two date filter by the other combobox.
Others combo box is working
Only you touch in the date fileds.
 

Attachments

  • DataBase (1).accdb
    864 KB · Views: 171
Last edited:

smtazulislam

Member
Local time
Today, 22:42
Joined
Mar 27, 2020
Messages
806
Have anyone there to review my code ?
Capture.PNG
 
Last edited:

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 03:42
Joined
May 7, 2009
Messages
19,169
Please check.
 

Attachments

  • DataBase (1) (1).accdb
    540 KB · Views: 221

moke123

AWF VIP
Local time
Today, 15:42
Joined
Jan 11, 2013
Messages
3,852
instead of changing the recordsource of the subform, use a filter.

Code:
Private Sub FilterMe()

    Dim strFilter As String

    If Not IsNull(Me![TDebut]) And Not IsNull(Me![TFin]) Then
        strFilter = strFilter & " And [Date_Operation] between #" & Me.TDebut & "# And #" & Me.TFin & "#"
    Else
        strFilter = strFilter
    End If

    If Not IsNull(Me.cbooperateur) Then
        strFilter = strFilter & " And [Operateur] = """ & Me.cbooperateur & """"
    Else
        strFilter = strFilter
    End If

    If Not IsNull(Me.cbotache) Then
        strFilter = strFilter & " And [Tache_effectuee] = """ & Me.cbotache & """"
    Else
        strFilter = strFilter
    End If

    If Not IsNull(Me.cbocharge) Then
        strFilter = strFilter & " And [Centre_de_charge] =""" & Me.cbocharge & """"
    Else
        strFilter = strFilter
    End If

    If Not IsNull(Me.cboclient) Then
        strFilter = strFilter & " And [Client] = """ & Me.cboclient & """"
    Else
        strFilter = strFilter
    End If

    If Nz(strFilter, "") <> "" Then
        strFilter = Mid(strFilter, 5)
    Else
        strFilter = strFilter
    End If

    Debug.Print strFilter

    Me.Base_sous_formulaire.Form.Filter = strFilter
    Me.Base_sous_formulaire.Form.FilterOn = True

End Sub

And instead of using a ZLS use null
Code:
Private Sub CmdClearFilter_Click()
    Me.TDebut = Null
    Me.TFin = Null
    Me.cbooperateur = Null
    Me.cbotache = Null
    Me.cbocharge = Null
    Me.cboclient = Null
End Sub
 
Last edited:

moke123

AWF VIP
Local time
Today, 15:42
Joined
Jan 11, 2013
Messages
3,852
works for me
 

Attachments

  • DataBaseSmt.accdb
    1,012 KB · Views: 218

smtazulislam

Member
Local time
Today, 22:42
Joined
Mar 27, 2020
Messages
806
See date is not fixed equal filter results.
 

Attachments

  • Capture.PNG
    Capture.PNG
    20.6 KB · Views: 186

Users who are viewing this thread

Top Bottom