PC SOFT

FORUMS PROFESSIONNELS
WINDEVWEBDEV et WINDEV Mobile

Accueil → WINDEV 2024 → [WD] How to change "search key" on a report
[WD] How to change "search key" on a report
Débuté par Gianni Spano, 21 oct. 2016 08:15 - 4 réponses
Posté le 21 octobre 2016 - 08:15
Hello to all

I have a report to print customers data from my application.
The report has a "search key" (with low and upper bound checked) based on the customer_name field and this is ok.

What i'm trying to do : Is it possible to "change" at runtime the "search key" field selecting one from the available other keys file? (like customer_code order)
I didn't find any information on the help.

Please, Can someone tell me if is it possible??

Thanks in advance

Gianni
Posté le 21 octobre 2016 - 08:25
Doing a deep search on the online help, i found this example, that i think is related to my needed:

// -- Opening code of the report
// Change the file browsed
RPT_Report1..SourceName = Customer
// New search item for "Customer" file
RPT_Report1..BrowsedItem = CustomerID


Is it the way i have to follow??

Thanks

Gianni
Posté le 21 octobre 2016 - 12:17
Hello

I think there is an OLD bug with "browseditem" on the report design.

This is the code i'm using to set the "search key" on the report:
SWITCH ASL_ReportMedici.RADIO_TipoStampa CASE 1 RPT_medici..SourceName=medici RPT_medici..BrowsedItem=medici.id CASE 2 RPT_medici..SourceName=medici RPT_medici..BrowsedItem=medici.id_cup OTHER CASE END iPreview(ipvZoom100, "Anteprima") iPrintReport(RPT_medici)
When i run the application, an error occurs (in french??):
Erreur à la ligne 3 du traitement Click BTN_Avvia.
Le champ 'RPT_medici' est inconnu.

How to resolve this issue?

Any hint or tip is appreciated.. :-)

Gianni
Posté le 21 octobre 2016 - 13:03
Hi Gianni,

Looks to me that you are trying to change the report properties outside the report.
Since the report is not opened yet you get the error that the report is unknown.
So you need to put your code in the report opening code and pass the BrowsedItem value to the report as a parameter (string).

Best regards,
Piet
Posté le 21 octobre 2016 - 13:38
Hello Piet

Thanks for the suggestion. It works!

I have used two global variables (gsSourceName and gsBrowsedItem)
Before to print the report both variables are set like:


gsSourceName="medici" gsBrowsedItem="id" // or "id_cup" depending on the user choice
and in the opening section of the report:
MySelf..SourceName=gsSourceName MySelf..BrowsedItem=gsBrowsedItem
And finally the report is printed as it is selected.

Thanks again

Gianni