Recent

Author Topic: Problem with MaskEdit component  (Read 4414 times)

ensimek

  • Jr. Member
  • **
  • Posts: 55
Problem with MaskEdit component
« on: May 09, 2010, 07:36:09 pm »
Hi Guys, the procedure is as follow:
procedure TLogowanie.MaskEdit1KeyPress(Sender: TObject; var Key: char);
var
   iloscznakow: string;
   iloscrekordow: longint;
   imieinazwisko: string;
   filtr: string;
begin
   iloscznakow := inttostr(length(MaskEdit1.Text)+1);

   if iloscznakow = '4' then
      begin
         Label3.Caption := '';
         Dbf1.FilePathFull := './database';
         Dbf1.TableName := 'users.dbf';
         Dbf1.Exclusive := True;
         Dbf1.Open;
         Dbf1.Active := True;
         // sprawdzam czy haslo jest komus przypisane
         filtr := MaskEdit1.Text;
         Dbf1.Filter := 'HASLO = ''' + filtr + '''';
         Dbf1.Filtered := True;
         Dbf1.Refresh;
         iloscrekordow := Dbf1.RecordCount;
         if iloscrekordow = 1 then
            begin
               Label3.Caption := inttostr(iloscrekordow);
            end;
         Label3.Caption := filtr;
         Dbf1.Active := False;
         Dbf1.Exclusive := False;
      end;
end;


The problem is that:
1. I wrote 4 chars in MaskEdit, but variables are saying that there's only 3 chars in MaskEdit, why?
2. Why filtering is not working ... even if MaskEdit.Text is '123' instead of '1234' there should be 0 records but lazarus is saying that there are 3 records (whole database records is 3)

ensimek

  • Jr. Member
  • **
  • Posts: 55
Re: Problem with MaskEdit component
« Reply #1 on: May 09, 2010, 07:50:44 pm »
I've changed onKeyPress to onChange and almost everything seems to work out.

The next problem is that Dbf1.RecordCount is couting a whole database, even if I write filter and there's only 1 record after filtering.

How can I count only displayed records?
« Last Edit: May 10, 2010, 07:05:08 am by ensimek »

ensimek

  • Jr. Member
  • **
  • Posts: 55
Re: Problem with MaskEdit component
« Reply #2 on: May 10, 2010, 03:28:59 pm »
Still have no idea how to count records after filtering .... please help

 

TinyPortal © 2005-2018