Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VFP6 DYNAMIC REPORTING 1

Status
Not open for further replies.

pamtru

Programmer
Jul 7, 2007
12
Hi!!!!. i have a grid that have field 1,field 2...field n. My clients wants a reports that shows only the fields that he had select. Is there a way to do this without having to make a report for each case.

Thank you very much.

Pamela
 
Well You could make a from with a combo box of all the fields in your table.
Allow the user to pick the fields they want and save the field names to an array. (You would have to limit the number of fields to 10 or something.
Take the array and make a table out of it.
Populate the table with either a Select statement or replace all's
SELECT * from mytable eval(array[1]) as field1 , ..... , into table rpttable
HAve a report built around the RptTable whit the field names Fields1, field2 ... etc.

The problem I see here is the field type and lengths. Do not know the structure of the table to be picked from so it may not be an issue.



David W. Grewe Dave
 
yes David i know the length and type of each field. My problem is how can i do to make the report looks this way


field1 field3


and not this way


field1 field3

(the empty space is for field2 but i dont want to use iif or conditional printing).

Thanks
Pamela
 
Pamela,

I wrote an article for FoxPro Advisor that desribes a function that does exactly what you want. Essentially, you create a cursor containing just the fields that you want to include the report. The function dynamically creates the report containing just those fields. You use a template to define the fonts, style, layout, etc.

I don't have the reference to the article to hand, but if it is of interest, go to and search for "Creating generic reports at runtime".

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Mike i found the link but i cannot see it because i am not a suscriber, is there another way or page where you have post your article?.

Thanks
Pamela
 
A bit late with this. I did this very thing (VFP6) generically by copying and hacking the FRX at run time. I have all of the fields on the report, some with sub-totals and totals in group bands. Once the user selects a report, I copy and hack the copy of the report and get the list of avalable fields from the FRX and present a list to the user. The user selects all of the fields they want from the list. The program goes through the list matching the list to the fields in the FRX and marks all of the non-printing fields "Print When" with .F. Then the code processes the "Printed" fields (and Sub-total fields) from right to left moving them to the left so there aren't any big white spaces where non-printed columns used to be. To reference the fields (and Sub-total fields) I simply came up with a naming convention that I put into the comment field in the report. Some of these are DTL-FieldName, PGHEAD-FieldName, GRPHEAD-FieldName, GRPFOOT-FieldName, SUM-FieldName, etc. Using these I can move an entire column. In some cases I even pass the white space I want between columns. I have also used this to control the lengths of lines on the report. If the user selects all of the fields, I simply use the original FRX unchanged. I also incorporated some buttons to select/de-select all fields. When the report finishes, simlpy delete the temp FRX. Hope this helps in some way.

Auguy
Sylvania, Ohio
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top