Results 1 to 5 of 5
  1. #1
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Canada
    Posts
    284
    Thanks
    0
    Thanked 0 Times in 0 Posts

    ONLY WANT TO PRINT ONE RECEIPT (Access 97)

    I have a Student School Fees database. I have a main Student form with a button that goes to the Payment form. I can then enter a payment. So I can enter several different payments if that is what they make. When I enter a payment, I want to print out a receipt. But when I print out the receipt (by way of a "Print Receipt" button on the Payment form), it prints out all the payments for that student. How can I get it to print just the payment I'm entering?

  2. #2
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,436
    Thanks
    1
    Thanked 34 Times in 34 Posts

    Re: ONLY WANT TO PRINT ONE RECEIPT (Access 97)

    I assume your print button is opening a report to print the receipt. But you aren't telling the report which payment to print. To do that, you need to use a WHERE clause in the OpenReport method. I'm assuming there is some sort of ID field to identify the payment you want. So the where clause needs to be something like: "TransID=" & txtTransID".

    Where TransID is the transactionID field in your record, and txtTransID is the control on your form that contains the TRANSid of the payment you want to print.

    See Help for OpenReport method to see how you have to modify you code.
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

  3. #3
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: ONLY WANT TO PRINT ONE RECEIPT (Access 97)

    If you're still trying to print this by printing the form, that's you real problem. Try Mark's suggestion instead. It works, and if you want, you can make the report *look* like the form.
    Charlotte

  4. #4
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Canada
    Posts
    284
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: ONLY WANT TO PRINT ONE RECEIPT (Access 97)

    Well, I tried what you said, but I still can't get it to work. Here is the code I used:

    Private Sub cmdPrintReceipt_Click()
    On Error GoTo Err_cmdPrintReceipt_Click

    Dim stDocName As String

    stDocName = "Payment"

    DoCmd.OpenReport stDocName, acPreview, , "PaymentID=" & "PaymentID"

    Exit_cmdPrintReceipt_Click:
    Exit Sub

    Err_cmdPrintReceipt_Click:
    MsgBox Err.Description
    Resume Exit_cmdPrintReceipt_Click

    End Sub

    PaymentID is my field name, and the name I gave the control in the Payments form. But it still doesn't work. If I have to give the control a different name, where do I go to change that? I tried giving it a different name in the Payments form, but it just asks for a parameter of txtPaymentID when I pressed the "Print Receipt" button. So I assume you have to go to some other places to change it, but I'm not sure where.

    Jen

  5. #5
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,436
    Thanks
    1
    Thanked 34 Times in 34 Posts

    Re: ONLY WANT TO PRINT ONE RECEIPT (Access 97)

    If your control name is PaymentID, and Payment ID is numeric, then the correct code should be:
    DoCmd.OpenReport stDocName, acPreview, , _
    "PaymentID=" & PaymentID

    Note that the 2nd PaymentID (which is the control) doesn't have quote marks. The line continuation is necessary, I used here here because the message widths are small.
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

Posting Permissions

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