Interactively Build a SELECT Statement Sample

File: ...\Samples\Solution\Forms\Makesql.scx

This sample shows how to make it possible for a user to build a custom query at run time. Combo boxes on the form make it possible for a user to choose fields from the currently open table. The BldSQL method processes the names of the fields and the values users type into text boxes to create an executable SQL SELECT statement.

Additional methods, ValidateType and SetTextboxFormat, make sure that the appropriate values are entered into the text boxes and correctly incorporated into the SELECT statement.

After the WHERE clause has been constructed and stored to the variable lcWhere, the following command creates the SELECT statement:

 CopyCode imageCopy Code
lcSQL = "SELECT * FROM " + lcAlias + " " + lcWHERE

Once the SELECT statement is constructed, it can be executed with macro substitution.

 CopyCode imageCopy Code

See Also

© , 1996-2020 • Updated: 11/10/20
Comment or report problem with topic