ApplyFilter with Boolean and String data (1 Viewer)

Inconspicuous

New member
Local time
Today, 06:25
Joined
Nov 14, 2013
Messages
3
I'm a nw user here (hi all,) and fairly new to VBA, so I'm hoping to get some direction.

I have a form used to gather data around some supplier details, and we have a review check box with Boolean data. I'm trying to establish a filter button to filter un-checked boxes by specific suppliers from a drop-down list.

Although I've been able to run filters on suppliers and the review checks separately, together I get a "Type Mismatch" error. I thought it might be because of the Boolean data type, so I tried converting that to String but get the same issue. Any insight will be appreciated!

So far what I've created is this:

Code:
Dim Chk1 As String
Chk1 = CStr([RevChk])
 
[FONT=Calibri]    DoCmd.ApplyFilter , (" Chk1 = " & Chr(34) & 0 & Chr(34) & "") And (" [Supplier Name] = " & Chr(34) & txtSupplSearch & Chr(34) & "")[/FONT]
 

David R

I know a few things...
Local time
Today, 05:25
Joined
Oct 23, 2001
Messages
2,633
Try:
Code:
"([Chk1] = " & 0 ") And ([Supplier Name] = " & Chr(34) & txtSupplSearch & Chr(34) &")"
You had a few too many quote marks in there. This is for Boolean of course.
 

Inconspicuous

New member
Local time
Today, 06:25
Joined
Nov 14, 2013
Messages
3
Thanks David, I'm not surprised about the quotes.

Although now I'm getting a syntax error around:

") And ([Supplier Name] = "
 

JHB

Have been here a while
Local time
Today, 12:25
Joined
Jun 17, 2012
Messages
7,732
Try:
Code:
"([Chk1] = " & 0 ") And ([Supplier Name] = " & Chr(34) & txtSupplSearch & Chr(34) &")"
You had a few too many quote marks in there. This is for Boolean of course.
It is missing a & sign after 0:
Code:
"([Chk1] = " & 0 [COLOR=Red][B]&[/B][/COLOR] ") And ([Supplier Name] = " & Chr(34) & txtSupplSearch & Chr(34) &")"
A stripped down version of the above, (because 0 is always 0):
Code:
"([Chk1] = 0) And ([Supplier Name] = '" & txtSupplSearch & "')"
 

JHB

Have been here a while
Local time
Today, 12:25
Joined
Jun 17, 2012
Messages
7,732
You're welcome, luck with you project.
 

Users who are viewing this thread

Top Bottom