check box in filter

T

Thomas Wright

I'm not able to get the else statement to filter properly. Using a noncheck
box statement, it works but using the check box just does not do it. If some
one could set me straight it would make life much brighter now. I'm using a
checkbox to indicate to filter a form based upon the current status of a
patient indicated by a checkbox (Check16).

Thanks .... Tom

Private Sub Check72_Click()
If Check72 = No Then
Me.FilterOn = False
Else
Me.Filter = "Check16 = 'Yes'"
Me.FilterOn = True
End If
End Sub
 
M

Marshall Barton

Thomas said:
I'm not able to get the else statement to filter properly. Using a noncheck
box statement, it works but using the check box just does not do it. If some
one could set me straight it would make life much brighter now. I'm using a
checkbox to indicate to filter a form based upon the current status of a
patient indicated by a checkbox (Check16).

Thanks .... Tom

Private Sub Check72_Click()
If Check72 = No Then
Me.FilterOn = False
Else
Me.Filter = "Check16 = 'Yes'"
Me.FilterOn = True
End If
End Sub


The 'Yes' you have is a string, but the va;use of the
Check16 Field os a true/False value. I don't try to use the
value names Yes or No, so I'm not sure if they even exist in
all environments (VBA, SQL, control expressions, ...). Use
True and False (without the quotes) instead.

If Check72 = False Then
Me.FilterOn = False
Else
Me.Filter = "Check16 = True"
Me.FilterOn = True
End If
 
T

Thomas Wright

The underlying table indicates Yes\No as the checkbox options. However, I
attempted with True\False with no pos. results.

Thanks

Tom
 
M

Marshall Barton

Thomas said:
The underlying table indicates Yes\No as the checkbox options. However, I
attempted with True\False with no pos. results.

Don't be confused by the name of a field's data type or its
format. Just because Access uses the user friendly(?) name
Yes/No for a boolean field doean't change the fact that it
is stored as a -1 (True) for Yes and a 0 (False) for No. To
further muddle the issue, you can choose to format a field's
value as "Yes/No", which has nothing to do with the field's
data type (any non-zero number will be displayed as Yes).

Take a look at the Check16 field in the the form's record
source **table** or query to see what the actual value is.
If it's not a -1 (when displayed as a number) then your
filter won't work.
 

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