filtering a field defined as Yes/No

K

kharpe

I have a field labeled FCSI_Closed that is defined as a Yes/No field that I
would like to filter on a continuous form based on an option group in the
header of the form. There will be multiple option groups to allow the user to
filter the form based on various criteria. I should be able to extrapolate
the remaining option groups based on the FCSI_Closed option group. The
following is the code that I have that the moment

Select Case RegulatoryFilter
Case "1"
stCriteria = "FCSI_Closed = 'True'"
Case "2"
stCriteria = "[FCSI_Closed] = 'False'"
End Select
Me.Filter = stCriteria
Me.Filter = True

I am getting a type mismatch. The stCriteria is defined as a string as my
understanding is that the Filter command requires a string input
 
M

Mike Painter

kharpe said:
I have a field labeled FCSI_Closed that is defined as a Yes/No field
that I would like to filter on a continuous form based on an option
group in the header of the form. There will be multiple option groups
to allow the user to filter the form based on various criteria. I
should be able to extrapolate the remaining option groups based on
the FCSI_Closed option group. The following is the code that I have
that the moment

Select Case RegulatoryFilter
Case "1"
stCriteria = "FCSI_Closed = 'True'"
Case "2"
stCriteria = "[FCSI_Closed] = 'False'"
End Select
Me.Filter = stCriteria
Me.Filter = True

I am getting a type mismatch. The stCriteria is defined as a string
as my understanding is that the Filter command requires a string input

True and False without single quotes.
"True" and "False" are strings.
 
J

John W. Vinson

I have a field labeled FCSI_Closed that is defined as a Yes/No field that I
would like to filter on a continuous form based on an option group in the
header of the form. There will be multiple option groups to allow the user to
filter the form based on various criteria. I should be able to extrapolate
the remaining option groups based on the FCSI_Closed option group. The
following is the code that I have that the moment

Select Case RegulatoryFilter
Case "1"
stCriteria = "FCSI_Closed = 'True'"
Case "2"
stCriteria = "[FCSI_Closed] = 'False'"
End Select
Me.Filter = stCriteria
Me.Filter = True

I am getting a type mismatch. The stCriteria is defined as a string as my
understanding is that the Filter command requires a string input

The Filter property needs to be a string... but a Yes/No field is not a text
string, and will never be equal to the text strings 'True' or 'False'. A
Yes/No field is actually stored as a number, -1 for True and 0 for False; the
SQL values True and False (without the quotes) are synonyms.

Try

stCriteria = "[FCSI_Closed] = True"

and similarly for False, or use -1 and 0 respectively.

Also, you need to set Me.Filter to stCriteria, and in the next line set
Me.FilterOn to True (rather than setting Me.Filter a second time).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top