CodeCharge Studio
search Register Login  

Visual PHP Web Development

Visually Create Internationalized Web Applications, Web Reports, Calendars, and more.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> General/Other

 Sum a column

Print topic Send  topic

Author Message
Jenny Horn
Posted: 01/20/2004, 3:08 PM

I have a search that looks at price or item name with a results grid that lists the items and their prices. Then the second grid to sums the price column for the entire result set (not just what is on the screen like the example in the help files). When I changed the Data Source Type from Table to SQL, the price search parameter suddenly was forcing a 0 default where it wasn't before. This made my sum empty unless they searched on that particular field. Once I removed the price from the were list the item description worked fine. So I put this custom code in the Before Execute Select event to get the behavior to be consistant with the other grid.

//Custom Code @25-1C57FE58
// -------------------------
global $products1;
// Write your own code here.
$p=CCGetParam("s_price",0);
if($p>0){
$products1->ds->SQL.=" and price = ".$p;
}
echo $products1->ds->SQL;
// -------------------------
//End Custom Code
peterr


Posts: 5971
Posted: 01/20/2004, 4:12 PM

Changing Data Source type from Table to SQL almost always involves some additional work because "Table" parameters are processed in a "smart" way. If a paramter doesn't exist then the program automatically removes the related part of the WHERE statement.
However, if you use SQL then the program passes the full control to you and you can write an SQL that will handle the missing parameters the way that you like. In this case I guess your Where SQL should look like:
WHERE  price = {s_price} OR {s_price}=0
(assuming "0" as the default value of the "s_price" parameter)

Note that for some users it is desirable that a parameter is required and in such case the standard variant should be sufficient:
WHERE  price = {s_price}

_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

MS Access to Web

Convert MS Access to Web.
Join thousands of Web developers who build Web applications with minimal coding.

CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.