Results 1 to 6 of 6
  1. #1
    Join Date
    Mar 2004
    Posts
    2

    Unanswered: Printing reports using information from a form

    I am currently working on a database that lets the user input information in a form and print a report based on this information.

    How do i get the database to print only the current record on displayed.

    I am using the following code

    DoCmd.OpenReport "RPTStatementOfPatient", acViewPreview
    DoCmd.OpenReport "RPTStatementOfHP", acViewPreview

  2. #2
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    Pass a variable to the report. In the recordsource for the report set your where criteria = ?. Then in the "query parameters" box for the "data" tab in the properties for the report, put an explicit reference to the criteria on the form.

    Eg if you are sorting a company table for just the company currently displayed on a form you could do something like:

    SELECT *
    FROM company
    WHERE company.company_id = ?

    Then in the query parameters:

    ? = Forms!YourForm!company_id

    All done.

  3. #3
    Join Date
    Feb 2004
    Location
    Indiana, USA
    Posts
    79
    DoCmd.OpenReport "YOUR REPORT", acViewNormal, , "[ID]=" & Me!ID

  4. #4
    Join Date
    Feb 2004
    Location
    Indiana, USA
    Posts
    79
    DoCmd.OpenReport "YOUR REPORT", acViewNormal, , "[ID]=" & Me!ID

  5. #5
    Join Date
    Feb 2004
    Location
    Indiana, USA
    Posts
    79
    Sorry for the duplicate post without adding personal comment. Was so excited that I knew an answer that when trying to edit the reply it got away from me.

    Perplexed

  6. #6
    Join Date
    Mar 2004
    Posts
    2
    Cheers guys got it working

Posting Permissions

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