Table
if Table
Table
finally
Screen
end;
end;
procedure TQueryForm
var
strAlias
strTable
strField
strValue
strWhere
strQuote
strQuery: string; { String used to construct the query }
frmQuery: TResultForm; { The Results form }
type
{ The following type is used with the Type drop
list
described in comments
etSQLOps = (soNoCondition
soEqual
soNotEqual
soLessThan
soLessEqual
soMoreThan
soMoreEqual
soStartsWith
soNoStartsWith
soEndsWith
soNoEndsWith
soContains
soNoContains
soBlank
soNotBlank
soInside
soOutside)
begin
{ Initialize the variables needed to run the query }
with ListBox
if ItemIndex =
raise Exception
else
strAlias := Items
with ListBox
if ItemIndex =
raise Exception
else
strTable := Items
with ListBox
if ItemIndex =
begin
if ComboBox
raise Exception
else
strField :=
end
else
strField := Items
if (Edit
(ComboBox
(ComboBox
raise Exception
else
strValue := Edit
{ See if the field being search is a string field
quote string with quotation marks; otherwise
if strField <>
with Table
if (DataType = ftString) or (DataType = ftMemo) then
strQuote :=
strQuote :=
{ Construct the WHERE clause of the query based on the user
in Type
case etSQLOps(ComboBox
soNoCondition: strWhere :=
soEqual: strWhere := strField +
soNotEqual: strWhere := strField +
strQuote;
soLessThan: strWhere := strField +
strQuote;
soLessEqual: strWhere := strField +
strQuote;
soMoreThan: strWhere := strField +
strQuote;
soMoreEqual: strWhere := strField +
strQuote;
soStartsWith: strWhere := strField +
strValue +
soNoStartsWith: strWhere := strField +
strValue +
soEndsWith: strWhere := strField +
soNoEndsWith: strWhere := strField +
strQuote +
soContains: strWhere := strField +
+
soNoContains: strWhere := strField +
+ strValue +
soBlank: strWhere := strField +
soNotBlank: strWhere := strField +
end;
if ComboBox
strQuery :=
else if Table
strQuery :=
else
strQuery :=
{ Create an instance of the browser form
frmQuery := TResultForm
{ Use a resource protection block in case an exception is raised
ensures that the memory allocated for the Results form is released
try
with frmQuery do
[
From:http://tw.wingwit.com/Article/program/Delphi/201311/25142.html