Page 2 of 2

Re: Report with criteria

Posted: Mon Aug 31, 2020 9:09 pm
by treed
The info from the link works to pass data from a launch form. This is useful and the hash tags in the SQL is an interesting concept. Is the MSAccess notion supported where a filter or where clause can be passed to the report via the code under the button? Or can the SQL for the report be changed from the code under the button? The reason I ask is that I frequently like to design reports where the user can select an item or not and get all of the records. I think MySQL will support conditional logic in the WHERE clause, but I've never needed to write SQL that way before and would make debugging a challenge.

Re: Report with criteria

Posted: Tue Sep 01, 2020 3:45 am
by kev1n
Create a PHP Procedure to create a temporary table.

https://wiki.nubuilder.cloud/ ... orts#Table
The point of using a Procedures is to create a temporary table that can be manipulated before it is used by the Report.

(If a nuTABLE or a nuSQL table is chosen, this temporary table is created automatically)


The temp table created must be called #TABLE_ID#.


#TABLE_ID# simply gets replaced by the name of a temporary table, created by nuBuilder, that will be used by the Report.
Using nuSetProperty() you can set Hash Cookies and use them in the Procedure. This is very powerful.

Example Procedure:

Code: Select all

$sql   = "CREATE TABLE  #TABLE_ID#";

$sql .= "

SELECT
    zzzzsys_object.*

FROM
    zzzzsys_object where sob_all_type = '#field00#'
    AND sob_all_table like '%#table_like#%'

";

nuRunQuery($sql);

Where field00 could be a field on your form and table_like a Hash Cookie that can be set (e.g. in the onclick event of a button) like this:

Code: Select all

nuSetProperty('table_like','zzzz')
Let me know if you have any questions.