How to Basics 101
Enviroment: Delphi 5.01, DBIsam 2.11, and ReportBuilder Demo 6.01
I've designed and previewed some reports and now want to implement them into
my project. What do I have to do at the form level to get the reports to
display?
Project design schema:
TformMain
TformCustList
The TformCustList form has a speedbutton that I want to have display the
"Customer List By Name" report. What do I have to do in the OnClick event?
procedure TformCustList.SpeedButton1Click(Sender: TObject);
begin
{
--------------- What do I put here? ---------------
}
end;
Thanks,
Craig Hunt
I've designed and previewed some reports and now want to implement them into
my project. What do I have to do at the form level to get the reports to
display?
Project design schema:
TformMain
TformCustList
The TformCustList form has a speedbutton that I want to have display the
"Customer List By Name" report. What do I have to do in the OnClick event?
procedure TformCustList.SpeedButton1Click(Sender: TObject);
begin
{
--------------- What do I put here? ---------------
}
end;
Thanks,
Craig Hunt
This discussion has been closed.
Comments
The following is what I ended up doing to get stored reports to work. Is
there anything wrong with this?
procedure TformCustList.SpeedButton1Click(Sender: TObject);
begin
DmRb.ppReport1.Template.DatabaseSettings.Name := 'Customer List by Name';
DmRb.ppReport1.Template.DatabaseSettings.DataPipeline := DmRb.plItem;
DmRb.ppReport1.Template.DatabaseSettings.NameField := 'Name';
DmRb.ppReport1.Template.DatabaseSettings.TemplateField := 'Template';
DmRb.ppReport1.Template.LoadFromDatabase;
DmRb.ppReport1.Print;
end;
Now I would like to find out:
(1) How to change the initial "Print Preview" Window size from half size to
full.
(2) How to change the initial "Print Preview" report display from the
smallest size to medium.
Craig Hunt
Thanks for sharing this information. I experimented a little bit with this
but IMO found it to be awkward and not really what I want to do. It's my
belief that when an end user wants to view a report before printing it, they
would prefer to see the report in a full-size Window, instead of the
crunched down size Window that ReportBuilder defaults to. Once the Print
Preview screen is displayed you can (1) maximize the Window and then (2)
increase the report size in the Window to give you something you can finally
read. But it would be so much nicer "not have" to do this each and every
time! That's way I was asking if there was is way to change the default size
settings for "Print Preview".
At this point, my assumption is that ReportBuilder does not have the ability
to do this...
** I would like an answer from someone at Digital Metaphors to either
confirm or deny this. **
If there is a way, I would surely like to know how.
Thanks again,
Craig Hunt
event handler on you form. This, way, every template that you load, will be
seen at 100% and in a maximized window. It's one line of code to assign the
event handler and two lines of code in the event handler. It will work for
every template that is loaded.
...
ppReport1.LoadFromDatabase.
ppReport1.OnPreviewFormCreate := ppReport1PreviewFormCreate;
...
procedure TForm1.ppReport1PreviewFormCreate(Sender: TObject);
begin
ppReport1.PreviewForm.WindowState := wsMaximized;
TppViewer(ppReport1.PreviewForm.Viewer).ZoomSetting := zs100Percent;
end;
Note: You will need to add ppViewr to the uses clause of your unit,
so that the ZoomSetting enumerated type is recognized by the
compiler.
Cheers,
Jim Bennett
Digital Metaphors
http://www.digital-metaphors.com
info@digital-metaphors.com
Thanks! That did exactly what I had wanted.
I'll be back. :-)
Craig Hunt
As I can now see, your suggestion was indeed part of the solution.
Jim Bennett of Digital Metaphors offered the same solution as you did, but
added a little bit more detail. That is what finally got me up and running.
=======================================
Here is his response:
After you load a template, assign the Report.OnPreviewFormCreate event to an
event handler on you form. This, way, every template that you load, will be
seen at 100% and in a maximized window. It's one line of code to assign the
event handler and two lines of code in the event handler. It will work for
every template that is loaded.
ppReport1.LoadFromDatabase.
ppReport1.OnPreviewFormCreate := ppReport1PreviewFormCreate;
...
procedure TForm1.ppReport1PreviewFormCreate(Sender: TObject);
begin
ppReport1.PreviewForm.WindowState := wsMaximized;
TppViewer(ppReport1.PreviewForm.Viewer).ZoomSetting := zs100Percent;
end;
Note: You will need to add ppViewr to the uses clause of your unit,
so that the ZoomSetting enumerated type is recognized by the
compiler.
=======================================
My mistake was in assuming that I had to "add" a TppViewer component to my
form. That's what got me going in the wrong direction.
I hope I can master ReportBuilder before it masters me!
Craig Hunt
customers post answers, so keep 'em coming, Dale.
Also, there is the TechTips newsgroup, which has the more popular how-to's
listed in categories and is a good place to try and find an answer. This
one is in the Formats andDevices(Report Output) in the Controlling the
Built-in Previewer post for future reference.
Cheers,
Jim Bennett
Digital Metaphors
http://www.digital-metaphors.com
info@digital-metaphors.com