clint
Posts: 3
|
Posted: 06/01/2009, 7:32 PM |
|
I am trying to dynamically add a "groupby" to the SQL statement. I assume the best way of doing this is to append it to the Where. First pass through works great and I can change the groupby via a list box in a search form and I do this via the beforebuildselect. All fine now. The problems start when typing in a search parameter, so the where statement changes to ...group by and p=... Ok not a problem...I will just do a replace to remove the group by string and append it to the end, but this does not work and in fact I can not even remove the whole where string by doing a grid.datasource.where = "" or Empty. Using 4.2.00 and any help or direction would be appreciated.
Thanks
******************SOLVED*************************
Trying to do things the hard way.....CCS puts the params in the where statement in the same order as they are in the visual query. Because I was trying to add something that was not in the list it was always being put at the beginning. So I WAS able to null the where statement, its just when I thought I was putting the group string at the end, CCS was sorting and putting it at the beginning. Just a visual illusion.
In the before build select the datasource.sql lists the entire query before you start messing with it, and then it is listed in each of the objects separately .ie sql, where, order. I never really saw this, since I was modifying, thus my problem. To replace the group portion I just did:
Grid.datasource.sql = LEFT(Grid.DataSource.SQL,InStr(1, Grid.DataSource.SQL, "GROUP BY")-1) & mygroupstring & " {SQL_OrderBy}"
|
|
|
|