Working with Filter and Yes/No values.

A

Ayo

How do I get this filter click sub to work when "Me.cmbFieldValues.Value"
values are "Yes/No". When I click on the comboBox for Me.cmbFieldValues.Value
I get 0 and -1 but when I click on the cmdFilter button I get and error
message "You canceled the previous operation." I don't know what this mean or
how to resolve this. Any help will be greatly appreciate.
Thank you.

Private Sub cmdFilter_Click()
If Me.cmbTrackerFields.Value = "Vendor" Then
Me.Form.Filter = "[Invoice Tracker].[" & Me.cmbTrackerFields.Value &
"]='" & Me.cmbFieldValues.Value & "'"
Me.Form.FilterOn = True
End if
End Sub
 
J

Jeanette Cunningham

Hi Ayo,
There is an excellent example of using form filters with code on
AllenBrowne's website.
He has a search form with all the code.
It shows you easy ways to build form filters.

The following line is most likely the problem
Me.Form.Filter = "[Invoice Tracker].[" & Me.cmbTrackerFields & "]='" &
Me.cmbFieldValues& "'"

I don't know all the details of your form, but something like this should do
the trick.
If Not IsNull(Me.[Name of combo with value you want to filter on]) then
Me.Filter = "[Name of field you are filtering on] = '" & me.[Name of
combo with value you want to filter on] & "'"
Me.FilterOn = True
end if

Note for a number field you use
Me.Filter = "[Name of field you are filtering on] = " & me.[Name of combo
with value you want to filter on]
You may also need to check that you are using the bound column of the combo

Jeanette Cunningham
 
A

Ayo

Thanks Jeanette. That fix one of the problems.

Jeanette Cunningham said:
Hi Ayo,
There is an anetteexcellent example of using form filters with code on
AllenBrowne's website.
He has a search form with all the code.
It shows you easy ways to build form filters.

The following line is most likely the problem
Me.Form.Filter = "[Invoice Tracker].[" & Me.cmbTrackerFields & "]='" &
Me.cmbFieldValues& "'"

I don't know all the details of your form, but something like this should do
the trick.
If Not IsNull(Me.[Name of combo with value you want to filter on]) then
Me.Filter = "[Name of field you are filtering on] = '" & me.[Name of
combo with value you want to filter on] & "'"
Me.FilterOn = True
end if

Note for a number field you use
Me.Filter = "[Name of field you are filtering on] = " & me.[Name of combo
with value you want to filter on]
You may also need to check that you are using the bound column of the combo

Jeanette Cunningham


Ayo said:
How do I get this filter click sub to work when "Me.cmbFieldValues.Value"
values are "Yes/No". When I click on the comboBox for
Me.cmbFieldValues.Value
I get 0 and -1 but when I click on the cmdFilter button I get and error
message "You canceled the previous operation." I don't know what this mean
or
how to resolve this. Any help will be greatly appreciate.
Thank you.

Private Sub cmdFilter_Click()
If Me.cmbTrackerFields.Value = "Vendor" Then
Me.Form.Filter = "[Invoice Tracker].[" & Me.cmbTrackerFields.Value
&
"]='" & Me.cmbFieldValues.Value & "'"
Me.Form.FilterOn = True
End if
End Sub
 
J

Jeanette Cunningham

Ayo,
I should also have said how to filter a Boolean field (True or False, also
known as Yes/No or 0/-1)
Post back if you are still having problems with the combo with Yes/No. Send
some more information about what you are trying to do.

Jeanette Cunningham


If Not IsNull(Me.[Name of combo with value you want to filter on]) then
Me.Filter = "[Name of field you are filtering on] = '" & me.[Name of
combo with value you want to filter on] & "'"
Me.FilterOn = True
end if


Ayo said:
Thanks Jeanette. That fix one of the problems.

Jeanette Cunningham said:
Hi Ayo,
There is an anetteexcellent example of using form filters with code on
AllenBrowne's website.
He has a search form with all the code.
It shows you easy ways to build form filters.

The following line is most likely the problem
Me.Form.Filter = "[Invoice Tracker].[" & Me.cmbTrackerFields & "]='" &
Me.cmbFieldValues& "'"

I don't know all the details of your form, but something like this should
do
the trick.
If Not IsNull(Me.[Name of combo with value you want to filter on]) then
Me.Filter = "[Name of field you are filtering on] = '" & me.[Name of
combo with value you want to filter on] & "'"
Me.FilterOn = True
end if

Note for a number field you use
Me.Filter = "[Name of field you are filtering on] = " & me.[Name of combo
with value you want to filter on]
You may also need to check that you are using the bound column of the
combo

Jeanette Cunningham


Ayo said:
How do I get this filter click sub to work when
"Me.cmbFieldValues.Value"
values are "Yes/No". When I click on the comboBox for
Me.cmbFieldValues.Value
I get 0 and -1 but when I click on the cmdFilter button I get and error
message "You canceled the previous operation." I don't know what this
mean
or
how to resolve this. Any help will be greatly appreciate.
Thank you.

Private Sub cmdFilter_Click()
If Me.cmbTrackerFields.Value = "Vendor" Then
Me.Form.Filter = "[Invoice Tracker].[" &
Me.cmbTrackerFields.Value
&
"]='" & Me.cmbFieldValues.Value & "'"
Me.Form.FilterOn = True
End if
End Sub
 

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