Using Combo Box to search for records

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • beemomo
    New Member
    • Jan 2008
    • 50

    Using Combo Box to search for records

    Hi, I have a single form - Customers and I wish to find out all the records which satisfied the value selected from combo box.


    Code:
    Private Sub cboFindFirstName_AfterUpdate()
        DoCmd.ShowAllRecords
        Me!ContactFirstName.SetFocus
        DoCmd.FindRecord Me!cboFindFirstName
        'Set value of combo box equal to an empty string
        Me!cboFindFirstName.Value = ""
    End Sub
    The result displayed only show the first record which satisfied the criteria. How can I make the rest of the records that also satisfied the criteria to appear? Please advise on this, thank you very much.
  • ajalwaysus
    Recognized Expert Contributor
    • Jul 2009
    • 266

    #2
    Sounds like you should use the .Filter function
    i.e.

    Code:
    Private Sub cboFindFirstName_AfterUpdate()
      If me.cboFindFirstName.value <> ""
        Me.Form.Filter = "FirstName = '" & me.cboFindFirstName.value & "'"
        Me.Form.FilterOn = True
      Else
        Me.Form.FilterOn = False
      End If
    End Sub

    Comment

    • beemomo
      New Member
      • Jan 2008
      • 50

      #3
      Thanks, ajalwaysus, it's works.

      Regards,
      Beemomo

      Comment

      Working...