Solved Why is my Filter not working? (1 Viewer)

cheberdy

Member
Local time
Today, 10:19
Joined
Mar 22, 2023
Messages
77
I want to find a record in a form. To do this, you enter a number and press a button. I have this filter code, but it does not seem to work. I already debugged it and the values are correct

Code:
Private Sub Befehl18_Click()
Dim number As String


number = Textfield1.Value
If Not IsNull(number) Then
Me.Filter = number
Me.Filter = True


End If


End Sub
 

CJ_London

Super Moderator
Staff member
Local time
Today, 09:19
Joined
Feb 19, 2013
Messages
16,637
Your filter needs to be something like

“somefield =“ & number
 

ebs17

Well-known member
Local time
Today, 10:19
Joined
Feb 7, 2020
Messages
1,952
1) Filtering means hiding everything that does not meet the filter condition, i.e. where the application of the filter condition results in False.
Code:
Me.Filter = True
With ALL True, there can be no data reduction.
@CJ_London shows you the right direction.

2) You don't just have to define a filter, you also have to actively use it.
Code:
Me.FilterOn = True
 

Gasman

Enthusiastic Amateur
Local time
Today, 09:19
Joined
Sep 21, 2011
Messages
14,370
I want to find a record in a form. To do this, you enter a number and press a button. I have this filter code, but it does not seem to work. I already debugged it and the values are correct

Code:
Private Sub Befehl18_Click()
Dim number As String


number = Textfield1.Value
If Not IsNull(number) Then
Me.Filter = number
Me.Filter = True


End If


End Sub
How is Access meant to know which field to search for that value?
Have you even looked up how to use a filter? :(

 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 16:19
Joined
May 7, 2009
Messages
19,246
I want to find a record in a form. To do this, you enter a number and press a button. I have this filter code, but it does not seem to work. I already debugged it and the values are correct
i also suggest reading a good material about MS Access.
it's hard programming blindly.
 

Gasman

Enthusiastic Amateur
Local time
Today, 09:19
Joined
Sep 21, 2011
Messages
14,370
i also suggest reading a good material about MS Access.
it's hard programming blindly.
Well there is always Google?
Either way you would still have to search, be it book or search engine.
 

Users who are viewing this thread

Top Bottom