Results 1 to 7 of 7
  1. #1
    5 Star Lounger
    Join Date
    Nov 2001
    Location
    Toronto Canada
    Posts
    920
    Thanks
    0
    Thanked 0 Times in 0 Posts

    2001 the Error (Access 2003)

    When I enter the number 4080 in the unbound box txtFilterBinNoSp and click on the cmdFilter button, I get

    Runtime Error '2001':
    You cancelled the Previous Operation

    This box/filter is used to select a specific number.

    When I enter the number 4080 in the unbound box txtFilter_01_wcard and click on the cmdFilter button, the record is retrieved correctly.

    This box is supposed to be a "wildcard" selector and works in this instance..

    Colour me confused.

    The following code has worked in a previous form,
    but hangs on the line

    Me.FilterOn = True

    which then gives me the error message.

    '==============================================
    Private Sub cmdFilter_Click()
    Dim strWhere As String
    Dim lngLen As Long
    Const conJetDate = "#mm/dd/yyyy#"
    '==============================================
    If Not IsNull(Me.txtFilter_01_wcard) Then
    strWhere = strWhere & "([SRT_CN] Like ""*" & Me.txtFilter_01_wcard & "*"") AND "
    End If
    '==============================================
    If Not IsNull(Me.txtFilterBinNoSp) Then
    strWhere = strWhere & "([SRT_CN] = """ & Me.txtFilterBinNoSp & """) AND "
    End If
    '==============================================
    lngLen = Len(strWhere) - 5
    If lngLen <= 0 Then
    MsgBox "No criteria", vbInformation, "Nothing to do."
    Else
    strWhere = Left$(strWhere, lngLen)
    Me.Filter = strWhere
    Me.FilterOn = True
    End If
    End Sub
    '==============================================
    Private Sub cmdReset_Click()
    Dim ctl As Control
    For Each ctl In Me.Section(acHeader).Controls
    Select Case ctl.ControlType
    Case acTextBox, acComboBox
    ctl.Value = Null
    Case acCheckBox
    ctl.Value = False
    End Select
    Next
    Me.FilterOn = False
    End Sub


    I have literally stripped out every other line of code in the form and have only one field left on the form:

    SRT_CN

    but still get the error message.

    I'd appreciate any help on this.
    Cheers,
    Andy

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: 2001 the Error (Access 2003)

    What is the data type of SRT_CN? (Text, number, date, ...)

  3. #3
    5 Star Lounger
    Join Date
    Nov 2001
    Location
    Toronto Canada
    Posts
    920
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: 2001 the Error (Access 2003)

    'Morning, Hans,

    SRT_CN is an autonumber field, ergo numeric, but other fields will be addressed which are text.

    Cheers,
    Cheers,
    Andy

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: 2001 the Error (Access 2003)

    You shouldn't put quotes around a numeric value: use
    <code>
    strWhere = strWhere & "([SRT_CN] = " & Me.txtFilterBinNoSp & ") AND "
    </code>
    (It's different if you use a Like condition, since concatenating with a wildcard such as * or ? results in a string value)

  5. #5
    5 Star Lounger
    Join Date
    Nov 2001
    Location
    Toronto Canada
    Posts
    920
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: 2001 the Error (Access 2003)

    Thanks Hans,

    You've started my day off on a super, bright note. Worked perfectly.

    Cheers,

    Andy
    Cheers,
    Andy

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: 2001 the Error (Access 2003)

    And a very early day it must be for you!

  7. #7
    5 Star Lounger
    Join Date
    Nov 2001
    Location
    Toronto Canada
    Posts
    920
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: 2001 the Error (Access 2003)

    Like they say, the early bird gets the worm. Which makes you wonder why the worm didn't sleep in.

    Cheers,
    Cheers,
    Andy

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •