Re: Runtime Error 2001,when setting filter.

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Thank you very much, now it works.(I found the code on internet, and was
making it work for me. obviously I haven't got the fundamentals right,
since I did not se that one)

/Lars

"Allen Browne" <AllenBrowne@xxxxxxxxxxxxxx> wrote in message
news:uJlxl3yaFHA.3040@xxxxxxxxxxxxxxxxxxxxxxx
> The message means that Access cannot complete the current action (turning
> the FilterOn), because the previous action is now found to be invalid. The
> previous operation is therefore assigning the string to the Filter, and
> the message is telling you that the Filter string you assigned is
> malformed.
>
> If ID is a Number field (not a Text field), lose the extra quotes, i.e.:
> Criteria = Criteria & " ID = " & Me![lstShipInfo].ItemData(i)
>
> That will still be invalid if ItemData(i) is null or a zero-length string.
>
> --
> Allen Browne - Microsoft MVP. Perth, Western Australia.
> Tips for Access users - http://allenbrowne.com/tips.html
> Reply to group, rather than allenbrowne at mvps dot org.
>
> "Lars Pedersen" <no> wrote in message
> news:OGPgk9uaFHA.3144@xxxxxxxxxxxxxxxxxxxxxxx
>> Hi there.
>> I am getting run-time error 2001 "You cancled the previus operation",
>> when my code reach
>> the frmFilterOn=true . I can not find out what operation it is talking
>> about and why, can anyone help me.
>> The code is on a popup search form, ID is autonumber that uniquely
>> identifies the record
>>
>> Code:
>> Private Sub cmdUseAsFilter_Click()
>> Dim Criteria As String
>> Dim i As Variant
>> Dim frm As Form
>> Set frm = Forms(Me.OpenArgs)
>> ' Build criteria string from selected items in list box.
>> Criteria = ""
>> For Each i In Me![lstShipInfo].ItemsSelected
>> If Criteria <> "" Then
>> Criteria = Criteria & " OR "
>> End If
>> Criteria = Criteria & " ID = '" & Me![lstShipInfo].ItemData(i) & "'"
>> Next i
>> ' Filter the form using selected items in the list box.
>> frm.Filter = Criteria
>> frm.FilterOn = True
>> DoCmd.Close acForm, Me.Name
>> End Sub
>
>


.



Relevant Pages

  • EXAMPLE: fill menu from path
    ... I wanted the ability to store any given filter to a user file, and be able to display it in a user organized menu system. ... Dim testPathsAs String ... Sub initForm() ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Combo allows not in list but after update causes runtime error
    ... Dim intNewContact As Integer, strtitle As String ... ' Evaluate filter before it is passed. ... ' Display message box asking if the user wants to add a new customer. ...
    (microsoft.public.access.modulesdaovba)
  • Re: Using VBA to filter a chart
    ... You could then append a WHERE statement to the string, ... > Dim qdf_Chart as QueryDef ... Normally I would use a query to filter the data then ... > use that query as the report data source. ...
    (microsoft.public.access.modulesdaovba)
  • Re: MULTIPLE SELECTION !!
    ... Dim CombinedText As String ... ' CombinedText now has the selected items from ListBox1 ...
    (microsoft.public.excel.programming)
  • Re: Filtering records on a form using multiple combo boxes
    ... So, then, you will need to build the Where string from that information, ... these 3 combo boxes have command buttons to activate the filtering ... filter the field in the record list box.. ... For the Agent Combo Box, ...
    (microsoft.public.access.forms)