General discussion

  • Creator
    Topic
  • #2087342

    Print report from Form in Access 2000

    Locked

    by ajd ·

    I want to print a Report from a button located on a Form. The Report must be limited to the record currently displayed on the Form. There are two fields on the Form that control the data that is to be displayed in the Report: a “MRNumber” field in the parent form and a “visit date” field in the child form.
    The Report is based on a query.
    I am using the following syntax in a Print Report button on the Form:

    DoCmd.OpenReport stDocName, acNormal, , [MrNumber] = [Forms]![Patient Billing details]![MrNumber] And [Visit Date] = [Forms]![Patient Billing details]![Patient Billing sub1]![Visit Date]

    The problem is the Report just ignores the Where clause and prints all records instead of the ones defined by the Form fields.
    Do I need anything in the Query to allow it to accept the parameters of the Where statement?
    Help!!

All Comments

  • Author
    Replies
    • #3730585

      Print report from Form in Access 2000

      by magetower ·

      In reply to Print report from Form in Access 2000

      You need to place the variable in the Criteria area for the field you are trying to filter on in the query.

    • #3730485

      Print report from Form in Access 2000

      by mbarker734 ·

      In reply to Print report from Form in Access 2000

      You line will work. You are just missing some quotes.

      DoCmd.OpenReport stDocName, acNormal, , “[MrNumber] = [Forms]![Patient
      Billing details]![MrNumber] And [Visit Date] = [Forms]![Patient Billing
      details]![Patient Billing sub1]![Visit Date]”

      The where must be a string.

      Good luck,

      Mark

      • #3757892

        Print report from Form in Access 2000

        by ajd ·

        In reply to Print report from Form in Access 2000

        You hit the nail on the head! Thanks very much. (I was so near, yet so far!)

    • #3757890

      Print report from Form in Access 2000

      by ajd ·

      In reply to Print report from Form in Access 2000

      This question was closed by the author

Viewing 2 reply threads