Access Report Control ??

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • meyvn77@yahoo.com

    #1

    Access Report Control ??

    I have a project using crash data where I would like a form to promp
    the user for 1 of the 8 stock report from a pulldown box with options A

    through E and a 'From' date and 'To' date. The options would be like
    crashes involving Fatalities, or Injury crashes, or Pedestrian
    crash...ect.. So each 1 of the 8 stock reports could have many
    variables.. I would like to know if I can use the control source or how

    I would go about programmicly in VBA setting the report source...


    like....
    Report.source =
    (Select * from Events
    where Events.Date between(" & Date1 & "," & Date2 & ")
    AND INJURY(or some other field) = " & Injury & ")


    Can you do this? Any help or a link to some documentation would be
    great.....


    Chuck

  • pietlinden@hotmail.com

    #2
    Re: Access Report Control ??

    Chuck,

    if you have to gather several criteria for your report, the easiest way
    is to use an unbound form. just drop the combobox onto your form and
    specify the recordsource. (The wizard should take care of most of it).
    Then add textboxes for the from and to dates.

    Once you have all your criteria collected, you can create your filter.
    (where clause) for your report. So in your code you would test your
    controls for non-null values and then add them to your filter string.

    like ...

    If not isnull(Me.Start Date) and not isnull(Me.EndDa te) then
    strDateFilter=" Between " & Me.StartDate & "and " & Me.EndDate
    end if

    then you'd do that for all of your criteria and then AND them together,
    so you'd end up with a single filter. Then you can just pass that
    filter in the open event of the report

    DoCmd.OpenRepor t "MyReport", ,, strFilter

    documentation.. . umm... see OpenReport in the help. Or
    www.mvps.org/access - there's a bunch of stuff there on doing this
    kind of thing.

    Comment

    Working...