Results 1 to 2 of 2
  1. #1
    Join Date
    Mar 2013
    Posts
    70

    Unanswered: filter form with combo box

    Access 2013
    Windows 7

    Hi, i know this is probably quite simple, but I cannot locate an answer or figure it out. I want to filter a split form datasheet based on a date in combo box. The field I want to use is in a combo box on the main section of the form. The field is a date field. Here is the SQL for the combo box that has the date field in it.

    SELECT tblDateLU.invDateID, tblDateLU.invDate
    FROM tblDateLU
    ORDER BY tblDateLU.[invDate];

    It is then stored in another table.

    Below is the code I have tried.

    Code:
    Private Sub cboFindDate_AfterUpdate()
    
    If IsNull(Me.cboFindDate) Then
        Me.FilterOn = False
    Else
    Me.Filter = "invDateID = '" & Me.cboFindDate & "'"
        Me.FilterOn = True
    End If
    
    End Sub
    Any help would be appreciated.

    Thanks, Scott

  2. #2
    Join Date
    Mar 2013
    Posts
    70

    filter form with combo box

    So I got this to partially work. It takes me to the records. I really would like to filter it.

    Code:
    Private Sub cboFindDate_AfterUpdate()
    
        Dim rs As DAO.Recordset
    
        If Not IsNull(Me.cboFindDate) Then
            'Save before move.
            If Me.Dirty Then
                Me.Dirty = False
            End If
            'Search in the clone set.
            Set rs = Me.RecordsetClone
            rs.FindFirst "[invDateFK] = " & Me.cboFindDate
            If rs.NoMatch Then
                MsgBox "Not found: filtered?"
            Else
                'Display the found record in the form.
                Me.Bookmark = rs.Bookmark
            End If
            Set rs = Nothing
        End If
    
    End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •