Trouble with Filtering records in a form based on unbound object

verdes

Registered User.
Local time
Today, 02:37
Joined
Sep 10, 2012
Messages
49
I am using Access 2007. I have a form in datasheet view that lists members in a member table (with the usual member info - name, contact info...) using a query that doesn't have a where clause (just an order by). Additionally the query has an expression that concatenates first and last name into a field called Member Name.

I want the user to be able to filter the results of the form with a wildcard entry on Member Name (or lastname)

I added an unbound text box to the header of the form and added an event procedure to it's onChange event that is supposed to set the filter - Me.Filter = "([Member Name] Like ' " & Me!txtFilter.Text & "*')"
Me.FilterOn = True

When I type in the textbox - it only allows me to enter 1 character and it doesn't find any records that match the textbox entry - because it moves the form to the new record. I'm at a loss. I've looked and looked and can't find or get an understanding of how you do this.... Can someone help me, Please?:confused:
 
Here is a small on change event that I often refer to. It may be useful to you.

I use it to create a where clause and update the rowsource of a lstbox. After each character, I requery the listbox.

Code:
Public Sub txtSearch_Change()
Debug.Print "In txtSearch_change " & Now

Me.lststaff.Requery
Me.Refresh
Debug.Print "WHERE " _
& "[Fieldname1] LIKE '*" & Forms!frmstaff!txtSearch & "*'   OR " _
& "[Fieldname2] LIKE '*" & Forms!frmstaff!txtSearch & "*'"

Me.txtSearch.SelStart = Me.txtSearch.SelLength
End Sub

If this isn't helpful, I suggest you show us all the code in the event procedure.
 
:pThank you! Thank you! Thank you!

That worked fine and I learned about the selStart and selLength attributes....
 
Glad to help. Good luck with your project.
 

Users who are viewing this thread

Back
Top Bottom