Link to home
Start Free TrialLog in
Avatar of venks
venks

asked on

Printing memo fields through Quickreport in Delphi 3

I have a table with memo fileds that are filled through othe tables at run tim in such
a manner that a carriage retun is embeeded after each line.
I want to print these through QuickReport Ver 2 k .
The  data of the table for a single record looks like this(for organising a
sports function giving events on different dates with actions to be taken
and resources required)

                   (Integer Field) (Date Field)

                    Ser            Date
                     1             29/10/1998

(Memo Field)         (memo Field)           ( memofield)

Event1               Action1                Resources1
Event2               Action2                Resources2
Event2               Action3                Resources3

I tried printing it through quickreport by using DBtext and DBrichtext.But only a blank appears
Regards
venks
Avatar of rwilson032697
rwilson032697

Try using the OnNeedData event in TQuickReport to fill in the memo field.

Cheers,

Raymond.
Avatar of venks

ASKER

Rwilson
I am sorry.But that is a very sketchy answer.Please give more details and if possible some code.
Regards
venks
Here is the help for TQuickRep...

Declaration

property OnNeedData : procedure (Sender : Tobject; MoreData : boolean)

Applies to

TQuickRep
TQRSubDetail

Purpose

OnNeedData is used when creating reports from sources other than Delphi datasources, such as string lists, arrays, text files and almost any other source imaginable. OnNeedData is called whenever QuickReport would normally issue a DataSet.Next command to move to the next record of a dataset. Setting MoreData to False will cause the report (or sub detail) to terminate.

Example

This code will print all strings in a TStringList to in a report:


var
   CurrentItem : Integer;
   SomeStringList : TStringList;

procedure TForm1.QuickRep1BeforePrint(Sender: TQuickRep;
var
   PrintReport: Boolean);
begin
   CurrentItem := 0;
   PrintReport := SomeStringList.Count > 0;
end;

procedure TForm1.QuickRep1NeedData(Sender: TObject; var MoreData; Boolean);
begin
   if CurrentItem <  SomeStringList.Count then
   QRLabel1.Caption := SomeStringList[CurrentItem];
   Inc(CurrentItem);
   MoreData := CurrentItem <= SomeStringList.Count;

end;

For more information on how to create event driven reports look at the chapter on this topic earlier in this documentation.

Instead of filling the QRLabel you would fill in a QRMemo...

Cheers,

Raymond
Avatar of venks

ASKER

Dear Rwilson
What i am looking for is to print the data in the DBmemo field of a table which is filled from fields of other tables.
The various lines of the dbmemo are terminated by a carriage return character
The code you have given is from the on line help for qreport
component which is not useful to me in this case.
Thanks anyway
regards
venks

Hi venks,

Use the QRDBText component for printing your dbmemo-fields, it's designed for that stuff (next to just printing labels).

Regards, Zif.
Avatar of venks

ASKER

Dear Tom
I have tried (i had mentioned that in my question also)
It does not work.I only get a blank space.
I used the quickreport expert also.Sometimes it shows only the first line of dbmemo field and other times nothing is shown where data should have been there.
Am i required to set some other property also
Even i find it strange that such a result is coming.
regards
vensk
oops, sorry looked over that last comment.

have you tried using wordwrap, autosize?

Have you tried to use a QRMemo and filling it manually to see what happens? .Lines.Text / .lines.Assign

There was a bug about blank lines, but this should be fixed in 2h.

Zif.
Avatar of venks

ASKER

Dear tom
I have not yet tried manual filling.Actually i used another component(free and text only report) and it fills up every thing
except that the lines of memo are misaligned and then you have to manually align it(painful and tedious)
I thought quick report should do the trick.But by default nothing is getting loaded.I have to quick report homesite and downloaded the FAQ.But nothing is mentioned as to the job at hand.
Before writing code i wanted to see whether Experts will help out
I will try rhe wordwrap and autosize and come back.
regards
venks
I look at an older project in which I've used DBMemo's.
Avatar of venks

ASKER

Dear Tom
Thanks
venks
venks,

I've looked at it and found that it I used it as :

TQRDBText
 Wordwrap = true and Autostretch = true

and it works perfectly.

Database = paradox.

Zif.
Is there any reason why you can't use the QRMemo Component, and then use the Lines.Assign Method in the BeforePrint Event of the Detail Band ?

I haven't got much time at the moment to give you a more detailed comment but if it's heading in the right direction let me know and I'll see what I can do tomorrow evening.

Darren

Avatar of venks

ASKER

Dear Tom
Your suggestion (TQRDBText Wordwrap = true and Autostretch = true ) worked and thanks a lot.
Please answer so that i can award the points
Now i am going to office and will award you the points later in the evening(by my time)
Regards
venks
ASKER CERTIFIED SOLUTION
Avatar of ZifNab
ZifNab

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of venks

ASKER

Dear Tom
Thanks once again
venks
no problem venks, we're here to help each other out. Zif.