Results 1 to 5 of 5
  1. #1
    Khalil Handal is offline Competent Performer
    Windows 10 Access 2010 32bit
    Join Date
    Jun 2016
    Posts
    310

    print selected record on a subform

    Hi,
    I have a form with SubForm for customers. I select a customer (from Combo box) on the main form and the payments are shown on the subform (view: Datasheet View).



    I need to add a command button to print an invoice (report already prepared) for a selected payment on the subform. How can I do that?

    Khalil
    Thanks in advance

  2. #2
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,559
    Pass in the CustomerID as the WHERE parameter when you open the report.
    Code:
        stLinkCriteria = "[Ship] = '" & Me.cboShip.Value & "'"
        
        'DoCmd.CopyObject , stParam, acReport, stRptName
            
        If Me.ChkPreview Then
            DoCmd.OpenReport stRptName, iPreview, , stLinkCriteria, iDialog
        Else
            DoCmd.OpenReport stRptName, iPreview, , stLinkCriteria, iDialog
            DoCmd.OutputTo acOutputReport, stRptName, acFormatPDF, stFTPpath & stParam & ".pdf", False
            DoCmd.Close acReport, stRptName
        End If
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  3. #3
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,772
    If you want report on only a single payment, then use PaymentID as filter criteria.

    DoCmd.OpenReport "rptPayment", , , "PaymentID = " & Me.subformcontainername!PaymentID
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  4. #4
    Khalil Handal is offline Competent Performer
    Windows 10 Access 2010 32bit
    Join Date
    Jun 2016
    Posts
    310
    Thank you.
    I passed the customerId and the PaymentId as filter criteria

  5. #5
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,559
    Well as June mentioned, all you really needed was the PaymentID. That would be unique.
    Good practice for combing more than one criteria though?
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 4
    Last Post: 05-11-2018, 12:18 PM
  2. Replies: 7
    Last Post: 12-04-2015, 09:45 AM
  3. Print only selected record of a sub form
    By falahsalih in forum Access
    Replies: 10
    Last Post: 05-11-2014, 09:28 AM
  4. Replies: 3
    Last Post: 02-11-2013, 04:43 PM
  5. How to Print Selected Record
    By indranx in forum Reports
    Replies: 2
    Last Post: 05-31-2011, 09:54 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums