Connecting Tech Pros Worldwide Help | Site Map

Open Report filtering from a listbox

 
LinkBack Thread Tools Search this Thread
  #1  
Old November 12th, 2005, 05:17 PM
diskoduro
Guest
 
Posts: n/a
Default Open Report filtering from a listbox

Hi!
I'm trying to get help to an unexpected problem that has appeared
while I was writing a new application.
I want to opeon a report of product sales by filtering previously from
a listbox in a previous form. In the listbox I have the complete
products list and I select the ones I want to be presented in the
report. I push a cmdButton and generate a String (wherecondition)
which I use with docmd.openreport. The string is generated this way:

Dim contador As Long
contador = 0
For Each ItemSel In Me!Lista02.ItemsSelected
'Generate the filter for the products list concatenating field
codart
'with quotations because that field is text.
strFiltro = strFiltro & "[tblProgram].[Codart] = " &
Me![Lista02].ItemData(ItemSel) & " OR "
contador = contador + 1
Next
'Supr the OR string at the end of the where condition
' if the filter exists

If strFiltro <> "" Then
strFiltro = "(" & Left(strFiltro, Len(strFiltro) - 4) & ")"
strFiltro = strFiltro
Here is my problem when I select more than 50 products
(approsimately)I have an error box. I think the problem is caused
because the where condition is limited in its longitude and when my
string gets longer, ms access protests. The string is generated with
product's code formed by 5 alfa-numeric digits.
The concrete question is: Does anyone know any other method that
allows me to get my report without this problem of longitude of
string. I wouldn't like to present to the user that he is not able to
select more than 40-50 different products.
Naturally, the option to select "all" the products it's not a problem
but the option to select multiple products that makes the string grows
longer is very usual in my final objective.

Thanks in advance! I know for sure that some of you will light my way.

  #2  
Old November 12th, 2005, 05:17 PM
MGFoster
Guest
 
Posts: n/a
Default Re: Open Report filtering from a listbox

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Use the IN keyword. E.g.:

....WHERE Codart IN ('abc12', 'xyz34', '25qrs')

If there is a limit on the size of the list (the items in the
parentheses) - I don't know it.

HTH,

MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBP+zgsYechKqOuFEgEQJY3wCgrIWw4si1KOEtiQ3Qv+Z37Y F+XnwAoOwu
hFLk1gcA8LxfG/7HHmub8AEO
=nfKK
-----END PGP SIGNATURE-----


diskoduro wrote:[color=blue]
> Hi!
> I'm trying to get help to an unexpected problem that has appeared
> while I was writing a new application.
> I want to opeon a report of product sales by filtering previously from
> a listbox in a previous form. In the listbox I have the complete
> products list and I select the ones I want to be presented in the
> report. I push a cmdButton and generate a String (wherecondition)
> which I use with docmd.openreport. The string is generated this way:
>
> Dim contador As Long
> contador = 0
> For Each ItemSel In Me!Lista02.ItemsSelected
> 'Generate the filter for the products list concatenating field
> codart
> 'with quotations because that field is text.
> strFiltro = strFiltro & "[tblProgram].[Codart] = " &
> Me![Lista02].ItemData(ItemSel) & " OR "
> contador = contador + 1
> Next
> 'Supr the OR string at the end of the where condition
> ' if the filter exists
>
> If strFiltro <> "" Then
> strFiltro = "(" & Left(strFiltro, Len(strFiltro) - 4) & ")"
> strFiltro = strFiltro
> Here is my problem when I select more than 50 products
> (approsimately)I have an error box. I think the problem is caused
> because the where condition is limited in its longitude and when my
> string gets longer, ms access protests. The string is generated with
> product's code formed by 5 alfa-numeric digits.
> The concrete question is: Does anyone know any other method that
> allows me to get my report without this problem of longitude of
> string. I wouldn't like to present to the user that he is not able to
> select more than 40-50 different products.
> Naturally, the option to select "all" the products it's not a problem
> but the option to select multiple products that makes the string grows
> longer is very usual in my final objective.
>
> Thanks in advance! I know for sure that some of you will light my way.[/color]

 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,840 network members.