Forum Discussion
Tony2021
Jan 23, 2025Iron Contributor
Filter Form with Like and Or
Hello Experts, I am having a tough time adding a condition to a filter on a form. It works with 1 condition but not sure about the OR part (sq, dq) Maybe it is correct. The error I get is "T...
- Jan 24, 2025
Try this:
Private Sub txtEndUser_AfterUpdate() ' http://allenbrowne.com/ser-28.html If IsNull(Me.txtEndUser) Then Me.FilterOn = False Else Me.Filter = "[Remarks 1] Like '*" & Me.txtEndUser & "*' OR [Remarks 2] Like '*" & Me.txtEndUser & "*'" Me.FilterOn = True End If End Sub
Tony2021
Jan 24, 2025Iron Contributor
perfect Kidd! Its odd that I need to use Me. since I leave that out of other queries (single criteria) but I assume you need the Me when its a multiple criteria query. I confirm it does work.
thank you very much!
Jan 25, 2025
Hi,
Me is good practice, but only really necessary if there would otherwise be name conflicts with variables etc. Your mistake and the crucial thing about the working variant is rather that the OR operator must be integrated into the string, i.e. it must be inside the quotation marks, which it was not in your variant.
Servus
Karl
****************
Access Forever, News, DevCon
Access-Entwickler-Konferenz AEK
- Tony2021Jan 27, 2025Iron Contributor
thank you for that follow up Karl. It makes sense. tricky indeed.