QueryPrepare

QueryPrepare /OpenQuery - problems from within a Smart browser. V9.1C - Windows 98

I am using SmartObjects – Smart Window
Smart Data Object
Smart Browser (Just codes and description)
SmartViewer
SmartDynaToolbar.

The Data Object uses - for each ana-codes as its query.


The Smart Window does the following when it is initialised as ana-codes is used for various analysis types.

ASSIGN qhdlchar = DYNAMIC-FUNCTION('getDataHandle':U in h_dana-code)
qhdl = WIDGET-HANDLE(qhdlchar)
buffhdl = qhdl:get-buffer-handle(1)
qrystring = " FOR EACH " + buffhdl:name + " WHERE ana-type = '"
+ ltmpcategory1 + "' NO-LOCK ". /* passed through – BS in most cases */

IF VALID-HANDLE(qhdl) THEN DO:

qhdl:QUERY-PREPARE(qrystring).
qhdl:QUERY-OPEN().
END. /*valid handle*/
PUBLISH "dataavailable" FROM h_dana-code ("Different":U).

I want to sort the Browser by code or description depending on the users requirements.

If I put a combo box on the window and have the following defined in the Window then the Browser works correctly and sorts into the correct sequence.

On VALUE-CHANGED of combo-box-1
cSort = (IF (combo-box-1:SCREEN-VALUE EQ ? OR combo-box-1:SCREEN-VALUE = "Code") THEN "ana-code" ELSE
"description”.

ASSIGN
byseq = "by ana-code"
ascdesc = "".

IF cSort = "description" THEN byseq = "by description".
IF lsort:SCREEN-VALUE = "descending" THEN ascdesc = "descending".

qrystring = " FOR EACH " + buffhdl:name + " WHERE ana-type = '"
+ ltmpcategory1 + "' NO-LOCK " + byseq + " " + ascdesc.

IF VALID-HANDLE(qhdl) THEN DO:


qhdl:QUERY-PREPARE(qrystring).
qhdl:QUERY-OPEN().

END. /*valid handle*/
PUBLISH "dataavailable" FROM h_dana-code ("Different":U).


However it is required that the browser works in a similar way to windows in as much as when the heading on the browser is ‘clicked’ then the browser is sorted on that column.

I have changed the browser to have column searching checked and inserted a Trigger
START-SEARCH of br_table
And have inserted the following code

datasource = DYNAMIC-FUNCTION('getDataSource':U).
tmpqrystringdisp = " ana-codes.ana-type = " + ltmpcategory1 . /* as defined in the window - happens to be BS */
{set queryWhere tmpqrystringdisp dataSource}.
{set querySort csort dataSource}.
{fn openQuery dataSource}.

I then get the following error messages

BS must be a quoted constant or an unabbreviated, unambiguous buffer/field reference for buffers known to Query-Main (7378)
QUERY-PREPARE requires a valid non-null character argument for Query-Main (7321)


Has anyone any ideas how to make this work??



:confused:
 
Top