Group:  Microsoft Access ยป microsoft.public.access.formscoding
Thread: filtering a field defined as Yes/No

Geek News

filtering a field defined as Yes/No
kharpe 11/28/2008 11:54:00 PM
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

Re: filtering a field defined as Yes/No
"Mike Painter" <mddotpainter[ at ]sbcglobal.net> 11/29/2008 12:11:08 AM
kharpe wrote:
[Quoted Text]
> 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.


Re: filtering a field defined as Yes/No
John W. Vinson <jvinson[ at ]STOP_SPAM.WysardOfInfo.com> 11/29/2008 12:20:50 AM
On Fri, 28 Nov 2008 15:54:00 -0800, kharpe <kharpe[ at ]discussions.microsoft.com>
wrote:

[Quoted Text]
>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).
--

John W. Vinson [MVP]

Home | Search | Terms | Imprint Contact
Newsgroups Reader - provided by WiredBox.Net