Results 1 to 10 of 10
  1. #1
    Join Date
    Nov 2004
    Location
    Ireland
    Posts
    25

    Unanswered: Filtering fields using a textbox

    Hi all,

    I am trying to filter two fields called firstName and LastName using the afterUpdate procedure.

    here is the code im using

    Code:
    Private Sub txtboxFind_AfterUpdate()
        If Nz(txtboxFind, "") <> "" Then
    
        SubMembers.Form.Filter = "[FirstName] = '" & txtboxFind & "' OR [LastName] = '" & txtboxFind & "'"
        SubMembers.Form.FilterOn = True
    Else
        SubMembers.Form.FilterOn = False
    End If
    
    End Sub
    What I want to acheive is lets say you type part of a name- e.g- if you type "Kev" it will still return all records with kevin, kevins, etc. At present it will only return records for exact names you enter!

    Thanks in advance!

  2. #2
    Join Date
    Apr 2005
    Location
    Zagreb - Croatia
    Posts
    372
    Look at "DemoFilterNameA2000.mdb",
    I think it is what you need.
    Attached Files Attached Files

  3. #3
    Join Date
    Nov 2004
    Location
    Ireland
    Posts
    25
    Thanks.. I figured it out there myself.What i was doing wrong was say
    Code:
    ...= like ....
    Code:
    Private Sub txtboxFind_AfterUpdate()
        If Nz(txtboxFind, "") <> "" Then
    
        SubMembers.Form.Filter = "[FirstName] like  '*" & txtboxFind & "*'" _
        & "OR [LastName] like '*" & txtboxFind & "*'"
        
        SubMembers.Form.FilterOn = True
    Else
        SubMembers.Form.FilterOn = False
    End If
    
    End Sub
    Would you have any idea on how to filter a name if they enter both first name and second name..eg in your db..kevin aaab will return record 1..Im working on it at the moment.

    Thanks for your help MStef.
    Caoimhin
    Last edited by caoimhincryan; 06-30-06 at 08:26.

  4. #4
    Join Date
    Apr 2005
    Location
    Zagreb - Croatia
    Posts
    372
    Look at "DemoFilterNameA2000.mdb" a new one.
    Look at Query2, Query3, Form2.
    Open Form2 and try.
    Attached Files Attached Files

  5. #5
    Join Date
    Nov 2004
    Location
    Ireland
    Posts
    25
    That doesnt work for me.When I open Form2 and type in kevinos kevin, it says that the value entered isnt valid for this field. ??

  6. #6
    Join Date
    Apr 2005
    Location
    Zagreb - Croatia
    Posts
    372
    Don't type name, but choose from Combo box.

  7. #7
    Join Date
    Nov 2004
    Location
    Ireland
    Posts
    25
    Thats works fine.

    The thing is I will have alot of names in the database and would just like to type in the full name and the filter to search through my records..Still working on it here..Any ideas?

  8. #8
    Join Date
    Apr 2005
    Location
    Zagreb - Croatia
    Posts
    372
    Tel me how your table looks like.
    What is the Primary key, and other fields.

  9. #9
    Join Date
    Nov 2004
    Location
    Ireland
    Posts
    25
    Sample database enclosed. open form frmMembers and enter data in the textbox. what i want to do is that if you enter a first name and a second name that it will return all details for that record. e.g. type joe bloggs in the textbox and it will return that record..

    Thanks.
    Attached Files Attached Files

  10. #10
    Join Date
    Apr 2005
    Location
    Zagreb - Croatia
    Posts
    372
    Here it is. Open "frmMembers2" choose from combo box.
    Attached Files Attached Files

Posting Permissions

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