Earlier today I posted the following code which was creating an error for a
string filter and the TTable filter property.

procedure TForm1.Button1Click(Sender: TObject)
var  Buffer:  String;
     name : String[10];
     BuffSize : DWORD;
begin
    Buffsize := 128;
    SetLength(Buffer, Buffsize);
    GetUserName(PChar(Buffer), Buffsize);
    name := Trim(buffer);
    Table1.Filter := 'USERID = ' + chr(39)+ TRIM(name) + chr(39);
    Table1.Filtered := true;
    If not Table1.Active then
       Table1.Open;
end;

After many hours of trying to fix and just looking for solutions I decided
to see if the manual, D6, mentioned anything and I found a thing called
Quotestr() which was in a creating filters section. The italics code above
now looks like this


    Table1.Filter := 'USERID = ' + Quotestr(Name);

and it how works HOORAY!!!!

The only point to note is that the buffer field has to be trimmed other wise
to still fails.

Thank Moises for you help anyway.

Eion McIntosh
PPCS Ltd
---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz
To UnSub, send email to: [EMAIL PROTECTED] 
with body of "unsubscribe delphi"
Web Archive at: http://www.mail-archive.com/delphi%40delphi.org.nz/

Reply via email to