filter on form with VBA

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • tod4@wp.pl

    filter on form with VBA

    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.List Count - 1
    If Lstklienci.Sele cted(i) = True Then
    Indexgorny = Indexgorny + 1
    ReDim Preserve klienci(1 To Indexgorny)
    klienci(Indexgo rny) = "klient = " & "'" &
    Lstdyscypliny.C olumn(0, i) & "'"
    End If
    Next I

    warunek = Join(klienci, " Or ")
    DoCmd.OpenRepor t
    ReportName:="ra portklienci1",
    view:=acViewPre view,
    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

    #2
    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.ItemsSelect ed
    docmd.OpenRepor t "raportklienci1 ",acViewPreview , warunek
    'print the report or whatever
    docmd.Close... 'close the report
    next varItem

    Comment

    • Justin Hoffman

      #3
      Re: filter on form with VBA


      <tod4@wp.pl> wrote in message
      news:1121872307 .195165.155040@ g47g2000cwa.goo glegroups.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.List Count - 1
      > If Lstklienci.Sele cted(i) = True Then
      > Indexgorny = Indexgorny + 1
      > ReDim Preserve klienci(1 To Indexgorny)
      > klienci(Indexgo rny) = "klient = " & "'" &
      > Lstdyscypliny.C olumn(0, i) & "'"
      > End If
      > Next I
      >
      > warunek = Join(klienci, " Or ")
      > DoCmd.OpenRepor t
      > ReportName:="ra portklienci1",
      > view:=acViewPre view,
      > 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.


      Comment

      Working...