hello my friends ...
i would like to publish my first weblog post about a method i use to modify the report i use to print invoices.
in this method i get benefit from 2 of the properties of report objects that is:
comment and user data in the tab of report object properties dialog.
i use these properties to assign additional data to the object so that i can find it when i query the source table of the report and that will allow me to specifically change the position, width .. etc that will allow me to generate a dynamic report.
i uploaded a form here and its associated required table and report to show an example of the method.
in this form i designed a grid that will display the data of an invoice in details. the user can choose which column to print and can change the order of columns to fit his/her business needs.
with this idea, i have an application that can be used by different businesses without the need for me to design a special invoice report for each customer. most of the required data are available and the user can select the way he need his invoice and the way its columns ordered and these settings are saved (in a typical application) and the user can get the invoice printed in the way he wants.
to be oriented about this technique, download the zipped folder and run the form .
select the columns you need to print and reorder the columns in the way you want and then push the print button, select the folder that you downloaded that contain the needed report and table (rptinvoice.frx, rptinvoice.frt, basicreport.dbf, basicreport.cdx).
print the invoice and you will get what i need you to see. change orders and select and deselct again and see the change in the printed invoice.
note that i disabled some columns form being deselected. this is just to be more realistic, some columns are essential in the invoice.
you need to browse the table (basicreport.dbf) and see its structure:
you start by designing a complete invoice report and then take the needed data like the left position and width from the source .frx table of the report. the other fields in basicreport.dbf decide which column is printable and which need to be resized.
the main thing in the report, is that i (named) invoice headers, column fields, and the longitudinal separators.
the example form i posted is simple and not intended for use as is but it will give you the idea on how you can design similar one for your business applications. and there are many aspects and ways to use this idea and the code i used in the form is not the optimum even for me, i just intended to show the idea.

i use similar mechanism in one of my applications without the need to customize my reports for clients. they choose what and how the data they need to be printed in their invoices.

i will be glad to read your questions or suggestions.

here are some explanatory pictures:

this is the sample form:

select the folder you downloaded that contains the necessary files:

from foxite weblog

and here is the printed invoice reflecting the first set of selections in the first image above

from foxite weblog

and in the following photo, different set of columns selected and the columns re-ordered:

from foxite weblog

the resulting printed invoice will be like this:

from foxite weblog

and bellow is a picture for the basicreport.dbf, notice the fields that are used to control printability, resizability and the order of the named columns. r_width and r_left are the original width and left properties of the report objects that are to be manipulated, taken from the rptinvoice.frx table (fields width and hpos, respectively) after primary design, to be as a basic for any furthur calculations needed to reposition and resize the controls.

from foxite weblog

and bellow is a picture for the report in the designer in its basic primary alignments. what i did is that i assigned (names and types) to the controls  that i want to manipulate. names are in the user data property and types in the comment property of the object:

from foxite weblog

below is a picture of the report .frx as a table. notice the comment and user fields that i used to store the identifying data of the object

from foxite weblog

i wish that you study the code i included in the form and let me know your opinions.

ammar hadi ..... iraq

5 Responses to Dynamic Flexible Invoice Report

  • Anil Sharma says:

    Cool Idea Ammar, one of my friend Samir, From foxite he also using the vfp report as you have done. U can make a cool utility from your that idea so user can make report on the fly by just clicking on the form.

  • AmmarHadi says:

    Thanks Anil,

    In fact I posted this to share my idea (on the fly) :-). So, I think that posting it in this simple way give more opportunity to developers to understand the idea and study the code I used in the simple sample form.

    Building a tool is helpful but I believe that understanding the idea is more important and is easier this way than a perfect tool. And developers can extend this idea so much. It is a flexible approach and provide a wide range of ideas to run in the same way.

    The tool need time .. I hope I can do it sometime.

    Its my pleasure to read your comment in my blog. Thanks again.

  • Davide says:

    needed here

    I hope it is helpful.

  • lilikindsli says:

    brkgPE I want to say – thank you for this!

    -You are welcome.

  • Invoice Form says:

    it’s make me to use. help me.

    You are welcome.

Leave a Reply

Your email address will not be published. Required fields are marked *