RE: List Box to Filter Report
- From: Winger <Winger@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Mon, 13 Jun 2005 08:17:02 -0700
JaRa,
The code is now multiselecting, but I still get an error of "missing
operator" for each item selected.
I think some commas need to be inserted into the strWhere as they are text
values, but I still haven't got to grips with this yet.
Again, thanks for your time on this.
Winger
"JaRa" wrote:
> Yes Indeed sorry
> --
> - Raoul Jacobs
>
> The nature of developping is sharing knowledge.
>
>
> "Winger" wrote:
>
> > JaRa,
> >
> > I'm also assuming that in your code "iif(strSQL" should read "iif(strWhere"
> >
> > Winger
> >
> > "JaRa" wrote:
> >
> > > Sorry small correction
> > >
> > >
> > > Dim frm As Form, ctl As Control
> > > Dim varItem As Variant
> > > Dim strWhere As String
> > > Set frm = Forms!frmMatchRestoFund
> > > Set ctl = frm!PrintList
> > >
> > > strWhere = ""
> > >
> > > For Each varItem In ctl.ItemsSelected
> > > strWhere = strWhere & iif(strSQL="", "[FunderProgramme]=" &
> > > ctl.ItemData(varItem),
> > > " OR [FunderProgramme]=" & ctl.ItemData(varItem))
> > > Next varItem
> > >
> > >
> > > DoCmd.OpenReport "rptFunder1", acViewPreview, , strWhere
> > >
> > > --
> > > - Raoul Jacobs
> > >
> > > The nature of developping is sharing knowledge.
> > >
> > >
> > > "Winger" wrote:
> > >
> > > > I'm trying to create a string of values from a list box and pass this to the
> > > > WHERE condition to open a report.
> > > >
> > > > I've tried code given in previous posted answers, but when adapting it to my
> > > > own DB, I'm going wrong somewhere.
> > > >
> > > > Dim frm As Form, ctl As Control
> > > > Dim varItem As Variant
> > > > Dim strSQL As String
> > > > Set frm = Forms!frmMatchRestoFund
> > > > Set ctl = frm!PrintList
> > > >
> > > > strSQL = "[FunderProgramme]="
> > > >
> > > > For Each varItem In ctl.ItemsSelected
> > > > strSQL = strSQL & ctl.ItemData(varItem) & " OR [FunderProgramme]="
> > > > Next varItem
> > > >
> > > > strSQL = Left$(strSQL, Len(strSQL) - 22)
> > > >
> > > > DoCmd.OpenReport "rptFunder1", acViewPreview, , "([strSQL])"
> > > >
> > > >
> > > > The problems:
> > > > 1) The example I took this from had to truncate 12 characters off the string
> > > > as it was " OR [EmpID]=". If I change this to 22 because my code adds " OR
> > > > [FunderProgramme]=" I get an error message "invalid call or procedure".
> > > > 2) If I leave the truncate as "strSQL = Left$(strSQL, Len(strSQL) - 12), I
> > > > get a message box asking me for the value of "strSQL".
> > > >
> > > > Any pointers gratefully received.
> > > >
> > > > thanks
> > > >
> > > > Winger
> > > >
.
- References:
- List Box to Filter Report
- From: Winger
- RE: List Box to Filter Report
- From: JaRa
- RE: List Box to Filter Report
- From: Winger
- RE: List Box to Filter Report
- From: JaRa
- List Box to Filter Report
- Prev by Date: BusinessObjects automation
- Next by Date: Re: Form Coding
- Previous by thread: RE: List Box to Filter Report
- Next by thread: conditional formatting
- Index(es):
Relevant Pages
|