David,

The way that I usually do this sort of thing is to construct the whole where clause statement in a variable.

Two reasons, firstly, you can see the where clause as it will be when debugging and, secondly, because if I don't need to use a where clause I can set the variable to a space and the command won't fail.
Thus:

SET VAR vWhere_Clause = 'WHERE TableCol = ''Red'' ' -- 2 pairs of single quotes and another at the end. (Doubles in v2.11?)
SET VAR vSort_Clause = 'ORDER BY TableCol '

If you user is filling in the "Red" bit then you create the variable:
SET VAR vWhere_Clause = ('WHERE TableCol =' & '''' + .vFillin + '''') -- 4 single quotes added either side of the variable

If vFillin is null or blank you can:
SET VAR vWhere_Clause = ' '

Then, either way, your command should not produce an error - it might not produce any results but that's another problem:

EDIT USING [form] &vWhere_Clause &vSort_Clause

Regards,
Alastair.


--------------------------------------------------
From: "David Fowler" <[email protected]>
Sent: Thursday, June 03, 2010 4:43 PM
To: "RBASE-L Mailing List" <[email protected]>
Subject: [RBASE-L] - User defined search string

Is there a way to allow the user to enter a search string or "where clause"
?  I've done it in 2.11 by assigning a variable and having the variable
filled in (fillin x using "Enter search criteria") and then taking that
variable (x) and placing it after the Where in a select command ie. Select
LName from Job where .x (x being something along the lines of - date eq
12/1/2009 or Month eq May and Week eq One). Remember, this is from 2.11 so eq works and quotes aren't needed. I have tried this kind of set-up in 7.6,
but get a syntax incorrect error, even with correct use of = and '.

Thanks,
David Fowler




Reply via email to