Connecting Tech Pros Worldwide Forums | Help | Site Map

filter on form with VBA

tod4@wp.pl
Guest
 
Posts: n/a
#1: Nov 13 '05
Hi,

Im using such procedure on my form to filtering dates to raport:


Private Sub wyswietlraport Click()
Dim i As Integer
Dim Indexgorny As Integer
Dim warunek As String
Dim klienci() As String


If bpolewyboru = True Then
For I = 0 To Lstklienci.ListCount - 1
If Lstklienci.Selected(i) = True Then
Indexgorny = Indexgorny + 1
ReDim Preserve klienci(1 To Indexgorny)
klienci(Indexgorny) = "klient = " & "'" &
Lstdyscypliny.Column(0, i) & "'"
End If
Next I

warunek = Join(klienci, " Or ")
DoCmd.OpenReport
ReportName:="raportklienci1",
view:=acViewPreview,
wherecondition:=warunek
DoCmd.Close acForm, "frmFiltr1"
End Sub

This procedure is creating date box klient from where I can choose one
or few
value of klient and print report. When I choose a few values raport is
printed
with those (one raport with a few value of klient) But I would like
when I choose a few value of klient raport was printing for each value
separately.
For example when I mark klient1, klient2, klient5 raport is printing
for klient1 value first than klient2 value and klient5. Maybe someone
had similar problem earlier and know how to change procedure so that
to get such posibility.
Thanks for any help

Peter


pietlinden@hotmail.com
Guest
 
Posts: n/a
#2: Nov 13 '05

re: filter on form with VBA


Peter,
If you loop through the .ItemsSelected collection of the listbox and
open a report for each one, you use the Where condition to filter each
one. Instead of OR-ing them together, you can just do something like

for each varItem in lbx.ItemsSelected
docmd.OpenReport "raportklienci1",acViewPreview, warunek
'print the report or whatever
docmd.Close... 'close the report
next varItem

Justin Hoffman
Guest
 
Posts: n/a
#3: Nov 13 '05

re: filter on form with VBA



<tod4@wp.pl> wrote in message
news:1121872307.195165.155040@g47g2000cwa.googlegr oups.com...[color=blue]
> Hi,
>
> Im using such procedure on my form to filtering dates to raport:
>
>
> Private Sub wyswietlraport Click()
> Dim i As Integer
> Dim Indexgorny As Integer
> Dim warunek As String
> Dim klienci() As String
>
>
> If bpolewyboru = True Then
> For I = 0 To Lstklienci.ListCount - 1
> If Lstklienci.Selected(i) = True Then
> Indexgorny = Indexgorny + 1
> ReDim Preserve klienci(1 To Indexgorny)
> klienci(Indexgorny) = "klient = " & "'" &
> Lstdyscypliny.Column(0, i) & "'"
> End If
> Next I
>
> warunek = Join(klienci, " Or ")
> DoCmd.OpenReport
> ReportName:="raportklienci1",
> view:=acViewPreview,
> wherecondition:=warunek
> DoCmd.Close acForm, "frmFiltr1"
> End Sub
>
> This procedure is creating date box klient from where I can choose one
> or few
> value of klient and print report. When I choose a few values raport is
> printed
> with those (one raport with a few value of klient) But I would like
> when I choose a few value of klient raport was printing for each value
> separately.
> For example when I mark klient1, klient2, klient5 raport is printing
> for klient1 value first than klient2 value and klient5. Maybe someone
> had similar problem earlier and know how to change procedure so that
> to get such posibility.
> Thanks for any help
>
> Peter[/color]


Can you alter the design of the report so it produces, for example, one page
per client. This way the same code will work, just with a slightly
different report.


Closed Thread