Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Ken Murphy
  Where is Ken Murphy?
 Springhill
 Canada
 Ken Murphy
 To: Rupesh Vardam
  Where is Rupesh Vardam?
 Mumbai
 India
 Rupesh Vardam
 Tags
Subject: RE: How to print multiple reports in sequence for one table?
Thread ID: 104601 Message ID: 104629 # Views: 1 # Ratings: 0
Version: Visual FoxPro 6 Category: Reports and Printers
Date: Friday, August 18, 2006 3:57:10 PM         
   


> Hi Experts,
>
> I am doing one project for letters printing.
> My data is as below
> NAME PRINTCODE AMOUNT NARRATION
> VICTOR A01 100.00 CHQ NO 878455
> ANTHONY C05 500.00 CR CARD NO 44421441
> JOHN B02 750.00 CHQ NO 874541
>
> I want to print all records in to original serial (i.e. record no serial of the table). But the major problem is that I have to print different report fornat to different PRINTCODE as per the record field.
>
> I made logic as per that and in scan endscan llop i checked the PRINTCODE and as per do case condition i printed report only for that record. But print spooling and report generation speed is low on laser printer (i have 2000 record min. in one table).
>
> please help me in the above problem.
>
> Thanks in Advance.
>
> Rupesh Vardam


Rupesh,

If I understand you correctly, you are attempting to create the equivalent of a series of mail merges, the mail merge file being dependent on the value of YourTable.PrintCode. If PrintCode = 1, print letter1, if PrintCode = 2, print letter2, ... I also read that your primary problem is with the time it takes to print these reports. Using a VFP report, you probably have code that looks like:
SELECT MyTable
SCAN
   DO CASE	
      CASE PrintCode = 1
         REPORT FORM MyReport1 FOR RecordID = MyTable.RecordID
      CASE PrintCode = 2
         REPORT FORM MyReport2 For RecordID = MyTable.RecordID
      ...
   ENDCASE
ENDSCAN

While this construct will work, you can see that you are looping through the table in the scan, and each report will also loop through the table. If you have 2000 records, you will be looping through the table a minimum of 2001 times. This is why it is so slow.

If you didn't mind having the letters sorted by type, you could loop through the table once for each report type:
REPORT FORM MyReport1 FOR PrintCode = 1
REPORT FORM MyReport2 FOR PrintCode = 2
...

But this will mean that your reports are not printed in RecordID order - and if I read you correctly, this would be unacceptable.

Ravi suggests that you use Word Mail Merge. This would work if you only had one type of letter. Your problem here is that you have multiple types of letters, so this will not work for you.

The best way to handle the speed issue would be to loop through the table only once. You can do this with a scan, but then you are going to have to construct your letters programmatically. You can do this, but it means that you are going to have to create your own type of mail merge.

Begin by creating the text for each type of letter in the memo field of a table (you will probably need to add a memo field to the table where you define PrintCodes.) In this letter text, you would use tags like < Field >MyMergeField< /Field > (without the spaces) to identify your merge fields. Within your scan loop, you could then replace the tagged merge fields with the contents of that field. For example,
SCAN
   lcMergedText = STRTRAN(PrintCodes.LetterText,< Field >Surname< /Field>,ALLTRIM(MyTable.Surname))
   lcMergedText = STRTRAN(lcMergeText,< Field >FirstName< /Field>,ALLTRIM(MyTable.FirstName))
   ...
ENDSCAN

Using this type of construct, you could then populate a memo field in a cursor and run your report over that cursor (the report would only have one field in it - that cursor's memo field.) A better option might be to create a rich text file or a Word file on the fly. You could then do formatting on the fly as well (add bold or whatever.)

Ken
You shall know the truth - and the truth shall set you free. (John 8:33)

ENTIRE THREAD

How to print multiple reports in sequence for one table? Posted by Rupesh Vardam @ 8/18/2006 7:40:25 AM
RE: How to print multiple reports in sequence for one table? Posted by Vinay Pagaria @ 8/18/2006 8:37:02 AM
RE: How to print multiple reports in sequence for one table? Posted by Rupesh Vardam @ 8/18/2006 10:59:27 AM
RE: How to print multiple reports in sequence for one table? Posted by Ravi Taxali @ 8/18/2006 2:55:56 PM
RE: How to print multiple reports in sequence for one table? Posted by Ken Murphy @ 8/18/2006 3:57:10 PM