Results 1 to 2 of 2
  1. #1
    Join Date
    Dec 2003

    Unanswered: Problem with Printing Specific Records


    I have set up a DB for a car hire company and I have now completed it. I have made a report called, 'Invoice' and when the user is on a form called 'Rents', I want the Invoice report to be printed with the specific records on the screen. However, I don't want a print button - I want the specific record to be printed when the user saves the record - i.e. the invoice is printed automatically.

    I therefore entered this code into the OnClick event of the Save Record button…

    DoCmd.OpenReport stDocName, acViewNormal

    The problem is it prints out every single record in the Rents form, rather than just the one currently displayed on the screen.

    Is there a way to pass a TransactionID into the report, so that it only prints off that specific set of records?

  2. #2
    Join Date
    Mar 2003
    The Bottom of The Barrel
    Provided Answers: 1
    There are a few ways to do this. One of the ways I like to do this is to set the recordsource programmatically in the OnOpen event of the report. The OnOpen event triggers before the report is printed, so you can set any params you would like there. Essentially you would have something like:

    Me.Recordsource = "SELECT TransactionID, somefield, someotherfield FROM YourTable WHERE TransactionID = " & forms!yourform!transactionID.Value

    that's a fairly simple way of doing it. There are other methods, but that should hold you over.

Posting Permissions

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