Re: Buttons to change SQL in ADOQuery
- From: Jon Purvis <jon.purvis@xxxxxxxxxxxxxxxx>
- Date: Thu, 26 Apr 2007 09:00:28 -0500
Graham wrote:
I would like to be able to click on a set of small buttons captioned A, B, C etc, to change the SQL statement of an ADOQuery. in Delphi 6. The SQL refers to an Access table called HomeAd, and the buttons should filter out records where the Surname field begins with A,B,C etc.
This shows what I have done:
procedure TfmHomeAddMain.btnAClick(Sender: TObject);
begin
with HomeQuery do
begin
Close;
SQL.Clear;
SQL.Add('SELECT * FROM HomeAd');
if Sender = btnA then
SQL.Append('WHERE Surname LIKE''A%''');
Open;
end;
end;
Assuming the Button caption is only a single letter, this should work.
procedure TfmHomeAddMain.btnAClick(Sender: TObject);
var TempString: string;
begin
with Sender as TButton do TempString:=Caption;
with HomeQuery do
Close;
SQL.Clear;
SQL.Add('SELECT * FROM HomeAd WHERE Surname LIKE''TempString%''');
Open;
end;
end;
--
Jon Purvis
Texas Parks and Wildlife Department
Austin, TX
.
- References:
- Buttons to change SQL in ADOQuery
- From: Graham
- Buttons to change SQL in ADOQuery
- Prev by Date: Re: open a .tmx file with ado
- Next by Date: Re: Time Delay in opening a Table
- Previous by thread: Re: Buttons to change SQL in ADOQuery
- Index(es):