Header issues
lazarus / 52-LazReport
----------------------------------------------------------------------
laz_frank · 2022-03-24 14:45
Hi!
While LazReport seems to be pretty versatile and stable, there are
three quirks I haven't been able to find a fix for so far:
1) Sometimes the error '... Undefined symbol: SqlQuery."fieldname" '
appears, even though this field is displayed exactly like this in the
DB field list within LazReport designer. Most of the time the error
message points to a different band than where the field was actually
placed. Unfortunately, I can't reproduce this behaviour reliably yet.
2) When trying to print some master data fields in the page header
(option 'On first page' enabled), it doesn't print the correct values
of the current data record (see example below).
3) Option 'Show on all pages' makes no difference for master header
band regardless if enabled or disabled (see example below, option
enabled).
Any ideas of what I'm doing wrong? TIA!
Frank
----------------------------------------------------------------------
dseligo · 2022-03-24 22:25
Quote from: laz_frank on March 24, 2022, 03:45:50 pm1) Sometimes the
error '... Undefined symbol: SqlQuery."fieldname" ' appears, even
though this field is displayed exactly like this in the DB field list
within LazReport designer. Most of the time the error message points
to a different band than where the field was actually placed.
Unfortunately, I can't reproduce this behaviour reliably yet.
Do you get this error in design phase or when using report?
Quote2) When trying to print some master data fields in the page
header (option 'On first page' enabled), it doesn't print the correct
values of the current data record (see example below).
It would be great if you can make small test project with test data
and show what you would like to achieve.
Quote3) Option 'Show on all pages' makes no difference for master
header band regardless if enabled or disabled (see example below,
option enabled).
I didn't use it like this, but I just tried it and it shows on all
pages for me. What Lazarus version are you using? I tried this on
Windows 11, Lazarus 2.2.0.
----------------------------------------------------------------------
dseligo · 2022-03-24 22:32
Here is small test project I used to try 'Show on all pages' option
for Master header band.
----------------------------------------------------------------------
laz_frank · 2022-03-26 13:51
@dseligo: Thank you for taking the time to answer and providing a test
project!
1) I get the error during preview in the designer and when using
frReport.ShowReport.
2) Yes, maybe I'll find the time to finish a test project tomorrow.
What I want to achieve: As I couldn't force the master header to
appear on all pages, I tried to get the database fields of interest to
print within the page header. I expected to get data of first record
on the first page, but got data of the second record on the first page
(please compare page header data on page 1 with master data on the
same page).
3) I'm on Windows 10 and Lazarus trunk (2.3.0) but installed Lazarus
2.2.0 fixes and tried your test project: Works as expected. But when
the option 'Show on all pages' is disabled, nothing changes. So it's
just the other way around in your project than in mine.
----------------------------------------------------------------------
dseligo · 2022-03-27 22:46
Quote from: laz_frank on March 26, 2022, 02:51:38 pmBut when the
option 'Show on all pages' is disabled, nothing changes. So it's just
the other way around in your project than in mine.
Strange. It works as expected for me.
I attached project where 'Show on all pages' is not enabled, can you
try it?
If it shows master header on all pages then maybe there is something
wrong with your Lazreport installation. If it shows master header only
on first page then maybe you didn't disable 'Show on all pages'
properly.
----------------------------------------------------------------------
dseligo · 2022-03-27 22:54
Quote from: laz_frank on March 26, 2022, 02:51:38 pmI tried to get the
database fields of interest to print within the page header. I
expected to get data of first record on the first page, but got data
of the second record on the first page (please compare page header
data on page 1 with master data on the same page).
I just tried page header and I think it works as you would like it too
(only on first page it shows 0XX instead of 1XX because user dataset
isn't initialized yet).
I'd say that there is definitely something wrong with Lazreport
installation at your end.
I attached screenshot and project with master data's 'show on all
pages disabled' and added page header.
----------------------------------------------------------------------
laz_frank · 2022-03-28 08:53
Thank you for your continued support.
Your project with 'Show on all pages' disabled works also as expected
on Laz 2.2.0 (Fixes) as well as on Laz 2.3.0 (Trunk).
But if I enable 'Show on all pages' it still behaves as if it were
disabled.
So, both of your projects work as expected, but changing the option
'Show on all pages' has no effect on my side.
Quote... maybe you didn't disable 'Show on all pages' properly.
- in Lazarus IDE: open 'unit1' | F12 | double click on frReport1
- in LazReport designer: right click on master header band | click on
'Show on all pages' | right click on master header band again to make
sure that check mark has changed | Save report | Close
- in Lazarus IDE: Run | Clean up and Build ... | Clean up and build |
F9
EDIT 1: The option 'Show on all pages' works as expected if I don't
use 'Save report'. (???)
EDIT 2: Verified: The XML-Code of the report in unit1.lfm gets not
changed if 'Save report' has been used.
or
EDIT 3: The changes are written back to in a
reportname.lrf file, but the behaviour of the header band doesn't
change. So the value doesn't seem to be interpreted correctly when
run.
EDIT 4: If you leave the 'DataSet' field in the page header empty, the
correct data from the first master record will be displayed. I assumed
that if data from the master table should be displayed in the page
header, one has to enter the same dataset as for the master detail
band. But then data from another master record is displayed (point 2
of my first post).
----------------------------------------------------------------------
dseligo · 2022-03-28 14:47
Quote from: laz_frank on March 28, 2022, 10:53:31 amEDIT 1: The option
'Show on all pages' works as expected if I don't use 'Save report'.
(???)
EDIT 2: Verified: The XML-Code of the report in unit1.lfm gets not
changed if 'Save report' has been used.
or
In my example project report is stored within form (in .lfm file) and
you don't have to use 'save report' (or better, you shouldn't use
'save report') in this case.
What probably happens is this: report has flag 'IsChanged' or similar.
When you make a change in the report and press Save this flag is
cleared. When it's time to save it in a form, flag is cleared and
nothing is saved.
I just tried to add a memo to report, hit save and then close and re-
open form. Memo wasn't in the report.
So, don't use save when report is stored in the form.
----------------------------------------------------------------------
laz_frank · 2022-04-28 09:15
Quote from: laz_frank on March 24, 2022, 03:45:50 pm1) Sometimes the
error '... Undefined symbol: SqlQuery."fieldname" ' appears, even
though this field is displayed exactly like this in the DB field list
within LazReport designer. Most of the time the error message points
to a different band than where the field was actually placed.
Unfortunately, I can't reproduce this behaviour reliably yet.
This error message can be avoided if
Code: Pascal [Select][+][-]window.onload = function(){var x1 =
document.getElementById("main_content_section"); if (x1) { var x =
document.getElementsByClassName("geshi");for (var i = 0; i
frReport1.Options := [roIgnoreSymbolNotFound];
is used.
In my case the error was caused by fields that were listed in the
object inspector but were invisible in the design area. I still don't
know how these invisible fields came about, but I deleted them in the
object inspector and the error went away.