Filtering Error: "You Cancelled the Previous Operation"

G

Guest

I have a form that I've developed that shows data from all over my database,
grouping it all together and displaying it for the user's ease of use. There
are four status indicator columns on this form, each one either equal to
"Green", "Yellow", or "Red". At the bottom of each column is a drop-down
combo box I have added that allows the user to filter on a certain color, so
they can see what records have a certain status. They can search on "Green",
"Yellow", "Red", or "All", which removes all filtering.

Three of the four comboboxes work perfectly, but the fourth throws the
following error no matter what I click:

Run-Time Error '2001': You cancelled the previous operation.

The code for the combobox is almost identical to the others, the only
difference being the names of the comboboxes and the filtered fields:

cboForecastScheduleCol = "All"
cboForecastCostCol = "All"
cboOverallStatCol = "All"

If cboCostToDateCol.Column(0) = "Green" Then
Me.Filter = "IND_CTD = 'Green'"
Me.FilterOn = True
Me.Requery

Me.txtFiltered.Visible = True
ElseIf (cboCostToDateCol.Column(0)) = "Yellow" Then
Me.Filter = "IND_CTD = 'Yellow'"
Me.FilterOn = True
Me.Requery

Me.txtFiltered.Visible = True
ElseIf (cboCostToDateCol.Column(0)) = "Red" Then
Me.Filter = "IND_CTD = 'Red'"
Me.FilterOn = True
Me.Requery

Me.txtFiltered.Visible = True
ElseIf (cboCostToDateCol.Column(0)) = "All" Then
Me.Filter = ""
Me.FilterOn = False
Me.Requery

Me.txtFiltered.Visible = False
End If

I have tried setting me.dirty = False, I've tried using docmd.save to save
the record, nothing. The code is the exact same as works perfectly on three
other controls of the same time on the same form. What could possibly be
wrong?

Thanks,

Dustin
 
M

Mark A. Sam

Hello Dustin,

I run into that error a lot. I just trap it, something like this:

err_Section:

If err = 2001 then
Resume Next
Else
"Error " & err & ":" & err.description
resume next
End If


God Bless,

Mark A. Sam
 
G

Guest

Well, that code makes it so the error doesn't come up, but this also causes
it not to apply the filter. Since this error comes up every time I try to
filter using that combobox, it kinda means that combobox doesn't work at all.

Is there anything more to it?

Thanks,

Dustin
 
M

Mark A. Sam

Sorry, I didn't notice that that filtering wasn't working. Just as a long
shot, try removing the Me.Requery lines. Also you could try stepping through
the code to see where the error occurs.
 
G

Guest

I'm sorry, I guess I forgot that little detail. The error is occuring at the
following lines:

Me.Filter = "IND_CTD = 'Green'"
Me.FilterOn = True

(Or at the line where it sets the filter to 'Yellow' or 'Red', depending on
which one I click on.) Sometimes it occurs on the Me.FilterOn = True line,
but this is far less common.

Dustin
 
M

Mark A. Sam

You didn't forget to mention it, I forgot to read it. ;)

Whenever I get these type of problems, I just play around until I get a
solution. Is your db small (like under 2 mb) where you can email it to me?

If you want to send it to me use:

msam
AT
Promote
dot
Org

God Bless,

Mark
 
G

Guest

I appreciate the offer, but the database is rather large, and chock-full of
top-secret information that my employer would execute me for leaking. ;)

In any case, I figured it out. The problem was that I was attempting to
filter on a field that was calculated as an expression in the query source
for the form. We changed the grouping from 'Expression' to 'Group By', and
now it works fine.

Just FYI, but I really appreciate your time and helpfulness. Thank you!

Dustin
 

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

Similar Threads


Top