DetailBeforePrint error
Why would I get the error "DetailBeforePrint" when trying to print a report
after loading the template, when the report prints fine if accessed via the
report explorer. This doesn't happen on simple reports, but if there are
headers, footers and subreports it does fail with this error after using
LoadReport and then Print. This is Delphi 6 with RB 9 latest build. I do
remember having a similar problem back with RB 7 and I don't remember if
there was a solution. The question is really, what is it in the report that
causes this error mesage?
Mike Combellack
after loading the template, when the report prints fine if accessed via the
report explorer. This doesn't happen on simple reports, but if there are
headers, footers and subreports it does fail with this error after using
LoadReport and then Print. This is Delphi 6 with RB 9 latest build. I do
remember having a similar problem back with RB 7 and I don't remember if
there was a solution. The question is really, what is it in the report that
causes this error mesage?
Mike Combellack
This discussion has been closed.
Comments
fine when loaded from a template and printed, suddenly throws an error when
the following code is added....
Procedure DetailBeforePrint;
begin
Detail.Visible := (ReservationCodes['SomeDateField'] >=
CurrentDate)
end;
...the idea being to hide the detail based on a condition. If the report is
opened via the report explorer it prints fine and as required. Why does this
fail when using LoadReport ?
Mike Combellack
Is this an AV or an exception error that you are receiving? If so, what is
the full error message given? Also, if possible, try setting your library
path to \RBuilder\Source\ and your debugger to stop on exceptions to see if
you can trace where this error is occuring.
--
Regards,
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Thanks for the reply. This is an exception (ECodeError: Could not compile
program: DetailBeforePrint). Further investigation shows it happens whenever
I reference a field value from the dataset in the DetailBeforePrint
procedure. Code in this procedure that does not refer to any dataset value
does not cause the exception.
Again, this only happens when loading from a template using loadReport - via
the report explorer it works fine.
It is rather difficult to see where it occurs in RB - I set ShowPrintDialog
to FALSE and than call Print - this goes to a line in RB that says
FCancelDialog.ppShowModal and the exception occurs. I haven't gone further
into this.
Mike
a feeling it's not new. I think that loadReport doesn't open the dataset in
the same way as when using the report explorer...
Mike
I'm having a bit of trouble recreating this issue on my machine. Here are
the steps I'm taking...
1. Create a new report connected to a dataset (created in DADE) and some RAP
code in the DetailBand.BeforPrint event accessing the dataset.
2. Save it.
3. Place a report and button on a form, and in the ButtonClick event call
LoadReport, then preview.
--
Regards,
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Thanks again for looking at this. Your scenario works if you preview using
the report explorer method . However, I'm actually sending the report to a
file - but you can see the error if you set the report device type to
dtScreen (I'm using dtPDF but it's still the same problem) and then call the
print method for the report. The report doesn't compile correctly - it looks
to me as though the dataset is not opened (if I reference the values of the
elements on the form rather than the dataset I don't get the error but the
values are all blank). What do you think?
Mike
Regards
Mike Combellack
Sorry about the delay... my newsreader did not pick up your last response.
For future reference, if I do not reply within about 24 hours to a post,
feel free to contact me or post again to be sure I got it .
In the example I created, I did not use the explorer, I saved the template
file down to file and called LoadFromFile inside the TButton.OnClick event.
This did not seem to give me the error you received. Which
database/connectivity are you using? Are you able to create this error
using the DBDEMOS database? If so, please construct a small example that I
can run on my machine and send it in .zip format to
support@digital-metaphors.com and I'll take a look at it for you.
--
Regards,
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com