Diese Seite mit anderen teilen ...

Informationen zum Thema:
WinDev Forum
Beiträge im Thema:
Erster Beitrag:
vor 4 Jahren, 5 Monaten
Letzter Beitrag:
vor 4 Jahren, 5 Monaten
Beteiligte Autoren:
RAUL2, Arie, Viggo Poulsen, Peter Holemans

[WD] Reading a query parameter value inside a report

Startbeitrag von RAUL2 am 21.11.2013 20:29

Hi guys.

I have a report based on a query. I've wrote the SQL code for this query instead of using the editor. The query has 2 simple date type parameters.

The problem here is reading the parameters' values inside the report. When I try to read them I got this:

Error at line 1 of Post-Print of BODY process. [*]
is not an item or a parameter of query. New parameters must not be declared after query preparation. Check whether no syntax error occurred in the item or parameter name.

[*] I've tried in: body, end of doc, etc etc and always the same error. I use (for instance) info(QRY_something.param1) sintax to read it. I've already tried assigning the value to a control and so on. There's no sintax error as the message suggests.

Is it possible to read query parameters values inside a report? What I'm doing wrong?

Note: I already found a workaround for this: I declare 2 global vars outside of the report and later, I use those vars to assign the value to the parameters. Later, I use the same vars inside the report.... Anyway... I'd like to find a solution because in testing mode I don't have the 2 global vars.

Kind regards.


Hi Raul2

I use a query i have made as a standard query (not embedded). I made it with the query designer.
With the report on the screen, rightclick on the top and select Report Description.
In here I select at 'a query of the project' and then select my query.

Part of my select statement is
Fakturalinie.FirmaNr = {ParamFirmanr}
AND Fakturalinie.FakturaNr = {ParamFakturaNr}

in the embed Opening RPT_Faktura1 (server) I write

This works fine for me.

Best regards
Viggo Poulsen

von Viggo Poulsen - am 22.11.2013 09:21
Hi Raul,

If I recall correctly, the query parameters are reset after hExecuteQuery execution.
Therefore I guess that's why they are no longer available after the query is executed. You might set them in the report declaration code section so you know the values set within the report.


Peter H.

von Peter Holemans - am 22.11.2013 09:43
Thank you guys.

I think it might be what Peter says. The error message says something about "new parameters..." I actually don't understand this behavor but it seems that the parameters are no longer available inside the report. The query parameters are set with iInitReportQuery(); so, the query doesn't exist before the report execution.

I'll keep using my workaround. Anyway, I remember now there's a checkbox for independent HF context... maybe uncheching this...

Kind regards.

von RAUL2 - am 22.11.2013 20:12
you could
1. pass the values you need to the report when calling iPrintReport(RPT_youreport,value1,value1,etc) like calling any procedure.
2. you could also use global project vars
3. sometimes I store these values in the database and read them again in the report
4. in the query you mentioned you use EQUAL. If you add those field to the SELECT part of the query as well, you will have the value on every record. (this is of course not an option when using >,

von Arie - am 22.11.2013 21:15
Hi Arie. I'm using global project vars.

The reason for this thread is "test mode". It's easy and fast to test a report with F9. If I leave the parameters blank, WD realizes that the parameters set in the query (design time) must be used with the report. The problem is when you have an Internal report with the same parameters, and those must be initialized with iInitReportQuery(). Similarly, if I need to print in the report the parameters (let's say a date range) it would be useful to have those parameters' values at hand.


von RAUL2 - am 24.11.2013 20:51
Zur Information:
MySnip.de hat keinen Einfluss auf die Inhalte der Beiträge. Bitte kontaktieren Sie den Administrator des Forums bei Problemen oder Löschforderungen über die Kontaktseite.
Falls die Kontaktaufnahme mit dem Administrator des Forums fehlschlägt, kontaktieren Sie uns bitte über die in unserem Impressum angegebenen Daten.