Recent

Author Topic: Header issues  (Read 2015 times)

laz_frank

  • Newbie
  • Posts: 5
Header issues
« on: March 24, 2022, 03:45:50 pm »
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

  • Hero Member
  • *****
  • Posts: 1219
Re: Header issues
« Reply #1 on: March 24, 2022, 11:25:13 pm »
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.

Do you get this error in design phase or when using report?

Quote
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).

It would be great if you can make small test project with test data and show what you would like to achieve.

Quote
3) 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

  • Hero Member
  • *****
  • Posts: 1219
Re: Header issues
« Reply #2 on: March 24, 2022, 11:32:09 pm »
Here is small test project I used to try 'Show on all pages' option for Master header band.

laz_frank

  • Newbie
  • Posts: 5
Re: Header issues
« Reply #3 on: March 26, 2022, 02:51:38 pm »
@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

  • Hero Member
  • *****
  • Posts: 1219
Re: Header issues
« Reply #4 on: March 28, 2022, 12:46:18 am »
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.

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

  • Hero Member
  • *****
  • Posts: 1219
Re: Header issues
« Reply #5 on: March 28, 2022, 12:54:02 am »
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).

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

  • Newbie
  • Posts: 5
Re: Header issues
« Reply #6 on: March 28, 2022, 10:53:31 am »
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.
<Flags Value="48"/>  or <Flags Value="112"/>

EDIT 3: The changes are written back to <Flags Value.../> 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).
« Last Edit: March 28, 2022, 02:58:25 pm by laz_frank »

dseligo

  • Hero Member
  • *****
  • Posts: 1219
Re: Header issues
« Reply #7 on: March 28, 2022, 04:47:12 pm »
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.
<Flags Value="48"/>  or <Flags Value="112"/>

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

  • Newbie
  • Posts: 5
Re: Header issues
« Reply #8 on: April 28, 2022, 11:15:36 am »
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.

This error message can be avoided if 

Code: Pascal  [Select][+][-]
  1. 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.

 

TinyPortal © 2005-2018