Graham
2005-09-10 14:43:51 UTC
I have a well-used and reliable search form which uses an SQL in a unit as
follows:
procedure TfmSQLSearchDialog.sqListBoxClick(Sender: TObject);
var x: Integer;
begin
for x := 0 to sqListBox.Items.Count-1 do
if sqListBox.Selected[x] = True then
SelectedField := sqListBox.Items[x];
end;
procedure TfmSQLSearchDialog.sqOKBtnClick(Sender: TObject);
var EditEntry : String;
begin
if SelectedField = ' ' then
begin
MessageDlg ('Please select a field first', mtInformation, [mbOK],0);
SelectedField := sqListBox.Items[1];
end;
EditEntry := '"%'+ sqEditBox.Text +'%"';
try
if cboxNot.Checked then
with fmHomeAddMain.HomeQuery do
begin
Close;
SQL.Clear;
SQL.Add('SELECT * from HomeAd');
SQL.Add('WHERE');
SQL.Add(SelectedField);
SQL.Add('NOT LIKE');
SQL.Add(EditEntry);
Open;
end
else
with fmHomeAddMain.HomeQuery do
begin
Close;
SQL.Clear;
SQL.Add('SELECT * from HomeAd');
SQL.Add('WHERE');
SQL.Add(SelectedField);
SQL.Add('LIKE');
SQL.Add(EditEntry);
Open;
end;
finally
fmSQLSearchDialog.Close;
end;
end;
procedure TfmSQLSearchDialog.FormCreate(Sender: TObject);
var I : integer;
begin
for I := 0 to fmHomeAddMain.HomeQuery.FieldCount -1 do
sqListBox.Items.Add(fmHomeAddMain.HomeQuery.Fields[I].FieldName);
fmHomeAddMain.HomeQuery.Open;
end;
I used the adjsusted the above in another project. and it again worked fine.
I then created a new form inherited from the fist Search form, and adjusted
the Query etc used. But I now get :
<< Project raised exception class EOleException with message 'Parameter
Colour has no default value'. Process stopped. Use step or run to continue.
The Parameter can be Colour or Size or Weaight, whichever is selected in the
ListBox.
Sorry this is so long, but any ideas please ?
Graham.
follows:
procedure TfmSQLSearchDialog.sqListBoxClick(Sender: TObject);
var x: Integer;
begin
for x := 0 to sqListBox.Items.Count-1 do
if sqListBox.Selected[x] = True then
SelectedField := sqListBox.Items[x];
end;
procedure TfmSQLSearchDialog.sqOKBtnClick(Sender: TObject);
var EditEntry : String;
begin
if SelectedField = ' ' then
begin
MessageDlg ('Please select a field first', mtInformation, [mbOK],0);
SelectedField := sqListBox.Items[1];
end;
EditEntry := '"%'+ sqEditBox.Text +'%"';
try
if cboxNot.Checked then
with fmHomeAddMain.HomeQuery do
begin
Close;
SQL.Clear;
SQL.Add('SELECT * from HomeAd');
SQL.Add('WHERE');
SQL.Add(SelectedField);
SQL.Add('NOT LIKE');
SQL.Add(EditEntry);
Open;
end
else
with fmHomeAddMain.HomeQuery do
begin
Close;
SQL.Clear;
SQL.Add('SELECT * from HomeAd');
SQL.Add('WHERE');
SQL.Add(SelectedField);
SQL.Add('LIKE');
SQL.Add(EditEntry);
Open;
end;
finally
fmSQLSearchDialog.Close;
end;
end;
procedure TfmSQLSearchDialog.FormCreate(Sender: TObject);
var I : integer;
begin
for I := 0 to fmHomeAddMain.HomeQuery.FieldCount -1 do
sqListBox.Items.Add(fmHomeAddMain.HomeQuery.Fields[I].FieldName);
fmHomeAddMain.HomeQuery.Open;
end;
I used the adjsusted the above in another project. and it again worked fine.
I then created a new form inherited from the fist Search form, and adjusted
the Query etc used. But I now get :
<< Project raised exception class EOleException with message 'Parameter
Colour has no default value'. Process stopped. Use step or run to continue.
The Parameter can be Colour or Size or Weaight, whichever is selected in the
ListBox.
Sorry this is so long, but any ideas please ?
Graham.