Advertisement

04.29.2008 at 11:01AM PDT, ID: 23362951
[x]
Attachment Details

Run-time error '2001': You canceled the previous operation

Asked by afsfire in Access Forms, Access Coding/Macros

Tags: , ,

Trying setup this filter on a form. I got this code from someone that was using an option group in a form to filter the data using a regular field. I am trying to setup the same type of filter except i'm usng a field that is basically a combo box where the row source is from another table. The way it is  supposed to work is in the form is basically in each record you can select one of four choices for the field using a pulldown. Then you can filter the data to browse all of the records with the selected option using an option group radio button on the form. ther error that comes up when the filter is run is "Run-time error '2001': You canceled the previous operation Also the other difference is that I'm using the query that the Form was built on as the "Const strSQL = "SELECT * FROM " intead of a table as was used in the original code.



The code for the filter is here

Option Compare Database
Option Explicit

'Set default record source of form
Const strSQL = "SELECT * FROM ContractQuery"
Private Sub cmdFilterRecords_Click()

'Variable to hold filtered SQL string
Dim strFilterSQL As String

'Set default record source of form
'Const strSQL = "SELECT * FROM ContractQuery"

    Select Case Me!optFilterBy
    'Filter record source dependant on option checked
        Case 1
            strFilterSQL = strSQL & " Where [ContractStatus] = '[To Be Reviewed]';"
        Case 2
            strFilterSQL = strSQL & " Where [ContractStatus] = '[On Hold]';"
        Case 3
            strFilterSQL = strSQL & " Where [ContractStatus] = '[Revisions Sent]';"
        Case 4
            strFilterSQL = strSQL & " Where [ContractStatus] = '[Contract No Fully Executed]';"
         
    'If filter applied with no option selected use default record source
        Case Else
            strFilterSQL = strSQL & ";"
    End Select
   
' Set record source with filtered SQL
    Me.RecordSource = strFilterSQL
    Me.Requery

End Sub

Private Sub cmdRemoveFilter_Click()

' This procedure will restore the RecordSource to the original dataset.

    Me.RecordSource = strSQL & ";"

End SubStart Free Trial
[+][-]04.29.2008 at 12:16PM PDT, ID: 21465184

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Access Forms, Access Coding/Macros
Tags: Microsoft, Access, 2003
Sign Up Now!
Solution Provided By: Emil_Gray
Participating Experts: 1
Solution Grade: A
 
 
[+][-]04.29.2008 at 12:18PM PDT, ID: 21465220

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.29.2008 at 01:00PM PDT, ID: 21465653

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04.29.2008 at 01:07PM PDT, ID: 21465713

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.29.2008 at 01:24PM PDT, ID: 21465884

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628