A few methods you should look up in the help file...
Locate
FindNearest
FindNext
DisableControls
GotoKey
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On
Behalf Of Mike Osborne
Sent: Thursday, 10 June 1999 21:51
To: Multiple recipients of list delphi
Subject: [DUG]: What the 'L' is the problem?
I suspect the following has either a very complex or very stupid
explanation.
Advice please.
In a D1 app I display a grid from a query sequenced by Description. When
the user presses a character key I position in the grid to the first
entry with that letter. The Datasource gets detached and attached
because it looks ugly watching the progress and detached is much faster.
So far so good.
The function works fine for every letter other than the letter 'L'. I
have been through the alphabet on this, all but 'L' is OK. When 'L' is
pressed, the program terminates.
This same problem has been reported on a different (client's) machine
also. The problem occurs with different data as well. Same problem if
there is Description beginning with 'L' or not.
In debug I can trace it as far as the "while" loop - it seems to spin
out at that point.
procedure TViewer.FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if (Key = VK_RETURN) then
OKBtnClick(Sender);
if (not (chr(Key) < 'A') and (not (chr(Key) > 'Z')))
or (not (chr(Key) < 'a') and (not (chr(Key) > 'z')))
or (not (chr(Key) < '0') and (not (chr(Key) > '9'))) then begin
Screen.Cursor := crHourGlass;
DBGrid1.DataSource := Nil;
with qrydash do begin
if (copy(Fields[2].asstring,1,1) > chr(Key)) then begin
First;
end;
while ((copy(Fields[2].asstring,1,1) < chr(Key)) and (not eof)) do
begin
Next;
end;
{ if no entries for a letter, show previous highest entry }
if (copy(Fields[2].asstring,1,1) <> chr(Key)) and not eof then
begin
Prior;
end;
end;
DBGrid1.DataSource := DS;
Screen.Cursor := crDefault;
end;
end;
---------------------------------------------------------------------------
New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
Website: http://www.delphi.org.nz