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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multiple pages text report - no table in data env. 2

Status
Not open for further replies.

thetempuser

Programmer
Jan 14, 2013
10
0
0
RO
Hello,

I have a application that prints out orders, after data entered in a table, and modeled in a report. All works great.
Now I also need to create a contract for each order. Data for the contract will be pulled from a couple of fields in a form, to variables, and then into a report ( I just need the date of the contract and the sum, no need for table here) But there's a problem. The text of the contract is 4 pages long (if i copy it into msword). I can copy the text into a report, but I get "Page header band is to large to fit on page", if i use the header, same with the detail band. I know this has something to do with printer page layout, or the driver. I guess the text doesn't fit on one page. Why isn't vfp going to the second page, third... so on? I've also tried to import the whole contract.doc to a variable and add this variable to the report. I get an error regarding it's length. I just want to create this simple report with a lot of text (legal stuff) and 2 variables in it, so that i can "oxigenate" the workflow. Until now, I used to print out orders, then open up the contract.doc in msword, add the date, add the sum, check layout, print, next one. It would be great to make some sort of report, It would make my whole work easier.

Thank you.
 
Printing very long pieces of text in a report is always a problem.

Have you considered splitting the text into several smaller chunks - perhaps one chunk per paragraph? You could then store the chunks in separate records in a new table, and add each one separately to the report. Not an ideal solution, I admit, especially if the text is likely to change often, but it should work.

A more extreme solution would be to forego using VFP's report generator, and do the whole thing in Word, using Automation. But that would probably involve quite a lot of work.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Come to think of it, you don't need to do the whole thing in Word. You can adopt a half-and-half approach:

1. Do the report as at present.

2. Use Automation to open the contract text in Word. Insert the variable information into the document, and then print it.

3. Repeat for the next order.

That should be a lot simpler than doing the entire report in Word, and better than your present approach of opening Word manually.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Yeah, large amounts of text in Vfp reports seems not to go well. Shame. Anyway I'm gonna try your suggestion and split the text into A LOT of chunks, and append these into a table. Experiment with that a little bit, over the weekend.

My last resort is Automation, which I have no experience with, but I guess this is the best time to start playing with the process a bit.

Thank you for the help.
Have a great weekend.
Andrei.
 
You're welcome, Andrei. Let us know how you get on with the plan to split the text into small chunks. I know it's a bit of kludge, but with luck you should be able to crack it.

That said, don't be afraid of Automation. It's not that difficult, and it can bring a lot of benefits to your applications.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Hi Andrei,

Did you consider mailmerging your WinWord Document (the contract) with the data in your VFP-table?

hth

MK
 
I was also considering this approach: create 4 reports, 01.frx contains the text of the first page of the contract, 02.frx the second and so on. I believe data band or header band can handle 1 word page of text. Then I could combine the 4 frx files into a doc, and send this to the printer. I'll see how it goes.

I don't know what mailmerging is regarding VFP. I've searched it online and a few examples popped up, but there are to complex for me. If you could point me to a simple example that will be great.

Thank you for your help.
Andrei.
 
Andrei,

Then I could combine the 4 frx files into a doc, and send this to the printer.

If you mean combine the four files into a Word document, there's no point in doing that. You can use REPORT FORM ... NOPAGEEJECT to print them as a single print job from within VFP.

Regarding MailMerge, I think MK's suggestion was to do the whole order within Word. The main document would be the contract, and you would use MailMerge to insert the variable data from your tables. On that basis, you wouldn't use VFP in any way.

That said, you could set up a MailMerge document within Word but actually print if from VFP, but that means using Automation, which I think you are trying to avoid.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Hi,
I do this all the time. I have a contract in Word which reads the required data from the VFP table via ODBC.
Please have a look at
[link ][/url]
Mike you're right
Regarding MailMerge, I think MK's suggestion was to do the whole order within Word. The main document would be the contract, and you would use MailMerge to insert the variable data from your tables. On that basis, you wouldn't use VFP in any way.
hth
MK
 
I've tried 2 methods, the first one is faster, and you have much more control of the output, the second one needs to have word installed, but once the whole model-document is created, the results are better.

Method 1:

a. Create a table with one field (C 164). - test.dbf
b. I've cleaned the contract.doc a bit, meaning that I've arranged the punctuation, end of row, bulleting...
b. APPEND FROM TEST.TXT DELIMITED WITH TAB
d. Created a frx with test.dbf in the data env. On the title band I can have the 2 variables with some text (company logo, adress....) which will only be printed once, and this makes up the first page. On the detailed band I've just inserted the field from test.dbf, one line, from left to right of the page. I've formated the text to my liking, so that is displayed on single line. If the appended text is greater that 164, it won't be shown unless I transform the field from the details band into a two-rows field. Which takes to much space. I know, this is a limitation, but the effect is the one I'm after.

The whole detail band (the text of the contract) takes up 2 pages, so I get one page left for signatures, both parties. I used the Summary band.
This method works fine for now. I'm planning on creating more contract models, each with it's table and frx.

Method 2:
I just followed the MS example from here:
Link
It's slow, takes a lot of patience, until you get the whole model right. Once it's finished, you have much more control over the output file, because it's word, a text editor, not a frx.

I will try the mail merge procedure, when I get more time, it looks that the process is much more simple that it looks.

Thank you all for your help.


 
Your first method is more or less what I had in mind when I made my original suggestion. But I wonder why you are storing the text in a C(164) field, and why you are limiting the chunk to one line. You say there is a risk of the chunk of text being more than 164 characters. So wouldn't it be better to use a memo field, with "Stretch with overflow"? That way, the chunk can be as long as you like. And if you make each chunk equal to one paragraph, you would avoid any awkward end-of-line issues.

That said, given that you have got it working to your satisfaction, you might well prefer to leave things as they stand.

Mike



__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
I never knew what Stretch with overflow does, because I never used reports that much. I've tried it now, as you suggested, with a memo field (after inserting some text), and It's better than before, much better. I was storing the text into a C 164 field because it would not show the entire line of text, it would cut some text at the end of the line, so after simple a measuring I decided that 164 of character per line was ok, at a certain text size. Now I can load the whole file into memo, add this to frx, Stretch with overflow check, and save. Report finished.

Wayyyyyyyyyyyyy better. Again, thank you so much.

Andrei.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top