8 Replies Latest reply on Nov 14, 2013 2:14 PM by AmilValladarez






           Hello everyone:

           I'm working on a database that will create invoices and each invoice will have 5 items per page. I also created 2 (LayA & LayB) printing layouts because I need the invoice data to be displayed on the page differently when printed.

           What I would like to do is create a script that will allow me to move through layouts if a condition is true. For example:

           If the invoice has 5 items, it'll use layA to do the printing, but if the invoice has more than 5 items, it'll use LayB to do the printing. 

           I tried using the "if function" but I wasn't able to make it work the way I wanted it. I'm new to scripting so it's no surprise I can't figure it out on my own.  I hope someone can help.  Thanks.

        • 1. Re: Scripting

               Invoices should be printed from your LineItems table so more than 5 items will instinctively roll onto the second page and you can still sub-total (create sub-summary report).  It would work the same but remove your restrictions.  Simply place your Invoice and customer fields directly onto the LineItems layout in the heading.  :-)

          • 2. Re: Scripting

                 LaRetta's answer assumes that you have a related table of line items linked to your invoices. If this is not the case, you should modify your design so that you do have such a table.

            • 3. Re: Scripting

                   Thanks, Phil, indeed true … if using FIELDS to hold each item then they need to be switched to records related by the InvoiceID.  

              • 4. Re: Scripting

                     LaRetta & Phil:

                     Yes, I'm printing from the LimeItem table. The items do roll over the next page but the problem is that i designed the invoice layout based on some specifications I was given.  At the bottom of the page, there's a line that separates item #5 from the total box, but the line disappears when it goes into the 6th item. I figured that I could use 2 different printing layouts. One layout to show inly 5 items and th other layout to show invoices with more than 5 items. Also, if I have just one item on the invoice, the whole body go the page shrinks, I know that's what it supposed to do, but this isn't what I was asked to do, so I'm trying to find a way to go about doing this.

                • 5. Re: Scripting

                       From the LineItems layout, a an If step can use Get ( FoundCount ) to count the number of line items and switch layouts when there are more than 5. But you may also want to experiment with the differences in results produced between putting your "totals" fields in a trailing grand summary or a footer. The footer would keep things from "shrinking" when there is just one line item.

                  • 6. Re: Scripting

                         Thanks, Phil. I'm about to put to the test the advice you gave me. On another note, having my total fields on a footer helps, however, the footer will show on all pages and I don't want that. I want the total to be at the end of the report. 

                         Having just one item in the invoice, I'm going to have to create a script that will add 4 extra records (since I can only fit 5 items per page) so the body of the page expands all the way to the bottom. I think I can do that, but I get lost. I don't know how to make it work so that it adds 3 extra records when there are 2 items on the invoice and 2 extra records when there are only 3 items on the invoice and 2 extra items when there are 2 items on the invoice, etc.

                         I really appreciate all the help I've received. If there's more info you can provide, I thank you in advance.

                    • 7. Re: Scripting

                           You don't need to add any extra records if your "five items or less" layout uses a footer for the totals.

                      • 8. Re: Scripting


                             That's actually correct.

                             Fortunately, I have found a solution that does what I want. Thank you for your help. ;-)