[Gambas-user] gb.report2 Conditional sections

Bruce adamnt42 at gmail.com
Sun Nov 22 19:01:56 CET 2020


On 22/11/20 8:12 pm, Fabien Bodard wrote:
> Hi Bruce,
> 
> I need to know more about your need to go further.
> 
> 
> Le sam. 21 nov. 2020 à 19:27, Bruce <adamnt42 at gmail.com> a écrit :
>>
>> Is there a way to set a reportSection to print or not print given a
>> certain condition? For example, if there is no data for some reporthbox
>> then the hbox should not print but instead a reportLabel with "NO DATA"
>> should be printed.
>>
>> tia
>> bruce
>>
>> ----[ http://gambaswiki.org/wiki/doc/netiquette ]----
> 
> 
> 

OK, Fabien, here goes.

BACKGROUND
I am writing a series of programs that analyse and report on various 
databases and database tables. These check the logical validity of the 
data and report inconsistencies. These report perograms are to run in 
the middle of the night, so there is no user interacction, chron just 
runs the report program via gbx3.

An example is "check_duplicate_orders" (hereafter "CDO") which looks for 
instanes of orders created in the last 24 hours that look like they may 
be duplicates created by the user submitting an order, chnaging a detail 
and submitting it again. 99% of the time the report will be "empty".

DESIRED DESIGN
The CDO program runs its' validity checking logic on the orders database 
and if nay instances that nee to be followed up are encountered outputs 
the identification details to a "temporary" "suspects" table.
It then runs the contained report that prints the contents of that 
suspects  table to a file,

The report consists of a header, a body and a footer sections. What I 
want is 2 body sections, one that prints the details of each suspect 
order (Body) and one that just prints "NO SUSPECT ORDERS FOUND" 
(AltBody). So I want these two to be conditional on the "suspects" table 
row count.

WHAT I'VE TRIED
In the Report_Open handler I query the suspects table and if the result 
row count is > 0 set the body section DataCount to that value and the 
AltBody.Visible to false. Or if the row count is 0 then set the body 
section visible to false and the AltBody.Visible to true..
   If $CDO.RowCount > 0 Then
     hbxData.DataCount = $CDO.RowCount
     ' hbxData.Visible is True by default
     lblNoRows.Visible = False
   Else
     hbxData.Visible = False
     lblNoRows.Visible = True
   Endif

But both sections are always printed.

Is that clear now?

tia
bruce


More information about the User mailing list