Results 1 to 2 of 2
  1. #1
    Join Date
    Jul 2003
    Thanked 0 Times in 0 Posts

    customizing a report (Access 2000)

    I have build a report from a query all and when I run the report it gives me all the records. I want the report to rum by sections do I need to specify parameter. How can I get the report to run by section and not all records. Thanks

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Thanked 31 Times in 31 Posts

    Re: customizing a report (Access 2000)

    You can put a parameter in the query. Say that you want to limit the report to a single value for the field MyField. Enter an expression like [Which MyField] iin the Criteria row under MyField.
    When you open the query, or the report based on the query, you will be prompted to enter the value. You can even refer to the parameter in the report header or footer, if you wish: place a text box in that section with control source =[Which MyField].

    A more elegant solution is to put a text box or combo box on a form in which the user can enter or select the value. You can either replace the parameter of the query by an expression of the form


    or open the report from the form with a where condition. Say that you have a command button cmdReport.

    Private Sub cmdReport_Click
    DoCmd.OpenReport "rptMyReport", acViewPreview, , "[MyField] = " & Me.[txtMyField]
    End Sub

    Of course, you must substitute the appropriate names. The above example assumes that MyField is numeric. If it is a string field, use

    "[MyField] = " & Chr(34) & Me.[txtMyField] & Chr(34)

    and if it is a date, use

    "[MyField] = #" & Format(Me.[txtMyField], "mm/dd/yyyy") & "#"

    If you're using US date format, the Format function is not really necessary, but it guarantees that the code will work regardless of the user's date settings.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts