By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,561 Members | 3,221 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,561 IT Pros & Developers. It's quick & easy.

filter on form with VBA

P: n/a
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

Nov 13 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
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

Nov 13 '05 #2

P: n/a

<to**@wp.pl> wrote in message
news:11**********************@g47g2000cwa.googlegr oups.com...
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

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.
Nov 13 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.