Re: Runtime Error 2001,when setting filter.
- From: "Lars Pedersen" <no>
- Date: Wed, 8 Jun 2005 05:13:05 +0200
I found out, thanks again.
/Lars
"Allen Browne" <AllenBrowne@xxxxxxxxxxxxxx> wrote in message
news:eY525D2aFHA.1404@xxxxxxxxxxxxxxxxxxxxxxx
> WHERE ID IN (23,5,7,99,...)
>
> --
> 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:ODkGJZ0aFHA.3528@xxxxxxxxxxxxxxxxxxxxxxx
>> The filter may contain a bunch of OR's if the user was not very selective
>> in selecting criteria on the searchform, there could be up to 1500 of
>> them, - together with an longint.
>> I guess this is not a pratical way of doing this, maybe changing the
>> recordsource is better.
>> How do you make use of this IN() ?
>>
>> /Lars
>>
>>
>>
>> "Allen Browne" <AllenBrowne@xxxxxxxxxxxxxx> wrote in message
>> news:uJUArK0aFHA.3848@xxxxxxxxxxxxxxxxxxxxxxx
>>> How long is this filter?
>>> You should be able to assign any practical filter in code.
>>>
>>> If it's a multi-select list box, use IN () instead of a bunch of ORs.
>>>
>>> If the worst comes to the worst, you could build the complete SQL
>>> statement instead of just the Filter (which is the WHERE clause of an
>>> SQL statement), and assign it to the form's RecordSource.
>>>
>>>
>>> "Lars Pedersen" <no> wrote in message
>>> news:O1ahnvzaFHA.2996@xxxxxxxxxxxxxxxxxxxxxxx
>>>> But I ran into another problem, the filter will to long to be applied
>>>> :-(
>>>>
>>>> /Lars
>>>>
>>>> "Lars Pedersen" <no> wrote in message
>>>> news:%23M1yUgzaFHA.2124@xxxxxxxxxxxxxxxxxxxxxxx
>>>>> 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.
>>>>>>
>>>>>>
>>>>>> "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
>
>
.
- References:
- Runtime Error 2001,when setting filter.
- From: Lars Pedersen
- Re: Runtime Error 2001,when setting filter.
- From: Allen Browne
- Re: Runtime Error 2001,when setting filter.
- From: Lars Pedersen
- Re: Runtime Error 2001,when setting filter.
- From: Lars Pedersen
- Re: Runtime Error 2001,when setting filter.
- From: Allen Browne
- Re: Runtime Error 2001,when setting filter.
- From: Lars Pedersen
- Re: Runtime Error 2001,when setting filter.
- From: Allen Browne
- Runtime Error 2001,when setting filter.
- Prev by Date: Re: VB Front End Access BackEnd
- Next by Date: Re: Transposing query result
- Previous by thread: Re: Runtime Error 2001,when setting filter.
- Next by thread: changing Display Form/Page with vba
- Index(es):
Relevant Pages
|