Diego Duarte
Diego Duarte

Reputation: 41

Filter SubForm based on multiple criteria

I have a Form with a SubForm, i'm trying to filter based on a range of two dates and an Username (i take the criteria from 3 textboxes), the part of the dates works fine but when i press the button to start the filter, a pop-up shows saying "Enter parameter value" (even if i type the username in the textbox), i enter an username and filters correctly, but the parameter its kept and the filter won't work anymore, until i close the Form and open again, any ideas?

I don't know why ask me to enter a parameter if i have already the username in the textbox.

Here my code:

Private Sub Filter_Click()

    Dim QIL As Form
    Set QIL = Forms("QIL")

If IsNull(Me.username_textbox) Or IsNull(Me.date_from_textbox) Or IsNull(Me.date_to_textbox) Then
    MsgBox "Insert date or username"
Else
    With Me.Superlinks_subform.Form
        .Filter = "[Date] = #" & Format(Me.date_from_textbox, "mm\/dd\/yyyy") & _
     "# AND #" & Format(Me.date_to_textbox, "mm\/dd\/yyyy") & "# AND [User] = " & Me.username_textbox.Value & ""
        .FilterOn = True
    End With
  End If

End Sub

Regards

Diego.

Upvotes: 0

Views: 366

Answers (1)

braX
braX

Reputation: 11755

Assuming the field [User] is a String - include single quotes like this:

[User] = '" & Me.username_textbox.Value & "'"

Upvotes: 1

Related Questions