Full Version: Howcome my filter on true and false cant work
UtterAccess Forums > Microsoft® Access > Access Forms
kidmon
Can anyone help on correcting this code
Om trying to filter both yes and no box with this code
Private Sub cmdTrackATP_Click()
Me.Filter = "Forms!frmWIP!ATPCheck = True"
Me.Filter = (Me.Filter + " AND ") & "Forms!frmWIP!PreCheck = False"
Me.Filter = (Me.Filter + " AND ") & "Forms!frmWIP!A5Check = False"
Me.Filter = (Me.Filter + " AND ") & "Forms!frmWIP!SorCheck = False"
Me.Filter = (Me.Filter + " AND ") & "Forms!frmWIP!DownCheck = False"
Me.Filter = (Me.Filter + " AND ") & "Forms!frmWIP!BackCheck = False"
Me.Filter = (Me.Filter + " AND ") & "Forms!frmWIP!Sor2Check = False"
Me.Filter = (Me.Filter + " AND ") & "Forms!frmWIP!FQACheck = False"
Me.Filter = (Me.Filter + " AND ") & "Forms!frmWIP!CompleteCheck = False"
Me.FilterOn = True
End Sub
but somehow it dont work properly
can anyone help
ace
Try replacing False with 0 and True with -1
e.Filter = "Forms!frmWIP!ATPCheck = -1"
Me.Filter = (Me.Filter + " AND ") & "Forms!frmWIP!PreCheck = 0"
...
kidmon
do i need to change even for the last line???
e.FilterOn = True
the true to -1??
GroverParkGeorge
What does it mean to say, "it dont work properly"?
oes that mean it gives you inappropriate results?
Does that mean it fails and shows you an error message?
Does the filter work if you only use one of the lines? (Remark out all but the first one to see what happens?)
Does it work if you rewrite it this way?
Private Sub cmdTrackATP_Click()
Dim strFilter as string
strFilter = "ATPCheck = True"
strFilter = strFilter & " AND PreCheck = False"
strFilter = strFilter & " AND A5Check = False"
strFilter = strFilter & " AND SorCheck = False"
strFilter = strFilter & " AND DownCheck = False"
strFilter = strFilter & " AND BackCheck = False"
strFilter = strFilter & " AND Sor2Check = False"
Me.Filter=strFilter & " AND FQACheck = False"
Me.Filter=strFilter & " AND CompleteCheck = False"
Me.FilterOn = True
End Sub
kidmon
it dont give me the appropriate result
and the code u give me cant work cause those are the yes and no check box and i cant use string for it
ace
>Do you know that because you have tried it?
kidmon
ya i have try it
if i put it as string it will ask me to put in value even after i have tick the box
And by putting -1 and 0 the effect is still same as the one i use true or false
GroverParkGeorge
Again, what does it mean to say, "it dont give me the appropriate result"?
o you get
-No results?
-Wrong results?
-An error message?
And a filter IS a string: "ATPCheck = True"
That's why it's enclosed in quotes.
HAs Ace suggested, you could try " "ATPCheck = -1", but in either case, it's still a string.
George
GroverParkGeorge
Which value(s) are you being prompted for?
ace
If you are still trying to use "Forms!frmWIP!PreCheck = False" or
"Forms!frmWIP!PreCheck = 0" the only result will be 0 matches.
The syntax George showed you is correct.
kidmon
i have try the code that George give but the result still the same giving 0 matches
it is still giving the wrong result
This is a "lo-fi" version of UA. To view the full version with more information, formatting and images, please click here.