Call report from report - use the same printer

DenSterDenSter Member Posts: 8,305
We have a report that calls another report, and we want to have the second report use the same printer that was selected for the 'main' report. So the user selects a printer for report 1, and then for report 2 it should automatically use the same printer. Does anyone have a tip on how to do this?

Comments

  • kinekine Member Posts: 12,562
    Hmmm... it will be hard to do that... without using the Printer selection table, or some automation, may be best is to make the two reports into one...
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • klavinklavin Member Posts: 117
    I haven't tested this, but its just an idea, not necc. practical...If you had a form where they ran the reports

    A variable to hold the Printer Name in a textbox, tablerelation to Printer, form 356 Printers (at least in my US vers)

    Have them do the lookup, select a printer, and on the button that is firing off the reports init and insert records for that user and report ID in the printer selections then after the reports run delete those records. Get what I'm trying to say?

    Should be able to get the Report ID from OBJECTID... Let me know what you come up with; this may look ugly and all but it would probably work? :-k

    -Lavin
    -Lavin
    "Profanity is the one language all programmers know best."
  • krikikriki Member, Moderator Posts: 9,110
    That's the way I would do it. I already did it once and it works. The only problem is that you need to do a COMMIT before doing a RUNMODAL of the report. And afterwards you need to delete the records.
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • RoelofRoelof Member Posts: 377
    I have the same problem.
    Is there anyone out who actually got it to work?
    Roelof de Jonghttp://www.wye.com
  • klavinklavin Member Posts: 117
    Yeah, works great. I setup default printers for Sales Locations, as we have people selling constantly very often back-to-back processing sales orders with multiple locations across the country. To print to the printer in that facility I have...

    In Document-Print for sales delete any existing System Created entries (Boolean added to Printer Selections).
    If the user doesn't already have a Report Selection for their ID/Report ID, and the Location has a default sales printer setup, Create a new record for that user/report combination. Commit it. Run the report as normal, after the report runs, delete the entry I created.

    This way if something abnormal happened and the record wasn't deleted I catch it the next time they try to print by deleting all System Created entries for that user.

    This scenario was a problem I was trying to solve when I saw this post and wrote the response and realized I could use it to get rid of having duplicate reports just to get the different default printers. Can be used for many scenarios...

    Kevin
    -Lavin
    "Profanity is the one language all programmers know best."
  • kitikkitik Member Posts: 230
    I use something like this, but in my case I allready know the name of the printer, it's not an user choise.
    I use it when printing a document to PDF.

    1. Call the function "SelectPrinter". The printer name, the USERID and the report ID is given to the fucntion.
    It looks upon the Report Selection table. If the user already has a printer associated with the report, it is saved in variables, and deleted.
    A report selection line is created with the paramenters given.
    2. Call the report
    3. Call the function "RestorePrinter"
    The line created by SelectPrinter is deleted. If the user had a printer before, it is restored.

    Salut!
    Laura Nicolàs
    Author of the book Implementing Dynamics NAV 2013
    Cursos Dynamics NAV (spanish) : http://clipdynamics.com/ - A new lesson released every day.
  • RoelofRoelof Member Posts: 377
    No, this is not exactly what I mean. The back to back printing is not a problem. I have that already working. My problem is this: I want to print a Customer Statement report. During the run, when it prints a statement with open invoices for each customer, I want to include printing the Open Invoices. So basically: printing a statement with 4 open invoices, printing the 4 linked invoices, printing the next statement, printing the linked open invoices, etc..etc..
    Is that doable using 1 printer?
    Currently I have it working by creating a dummy report which loops thru the customers. For each customer I call the Customer Statement report to print. In the Customer statement report I added a call to the SalesInvoice report in the Report.OnPostReport trigger. That works but I thought there would be a more gentle way to get this to work.

    Let me know.

    PS: Laura, what do you have defined in your functions: SelectPrinterer and RestorePrinter?
    Roelof de Jonghttp://www.wye.com
Sign In or Register to comment.