Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 3 of 3 total
Thread Filter problem
Fri, Dec 16 2022 11:35 AMPermanent Link

Peter van Mierlo

EVENTSOFT

Avatar

Hi

I think I'm looking over something but can't see it anymore.

My FORM has onKeyPress event to scan a barcode or nfc-tag. The result should not be visible to the user.
So for testing the scan result is passed to a variable  to use it in a database filter. See code below

Because this gives an error message (see attachement)  I tried the following variations.
- assign scan result to a LABEL and use it in the filter -> result ERROR
- assign scan result to a EDITand use it in the filter -> result GOOD


Use  LABEL and gives ERROR:
dmMain.Scan.Refresh;
dmMain.Scan.Filter   :='LOWER(NumberBarcode) like LOWER('+QuotedStr(Label1.caption) +')';
dmMain.Scan.Filtered := True;

User VARIABELE and gives ERROR:
dmMain.Scan.Refresh;
dmMain.Scan.Filter   :='LOWER(NumberBarcode) like LOWER('+QuotedStr(sSenderBARCODE) +')';
dmMain.Scan.Filtered := True;

User VARIABELE and gives WORKS:
dmMain.Scan.Refresh;
dmMain.Scan.Filter   :='LOWER(NumberBarcode) like LOWER('+QuotedStr(Edit1.Text) +')';
dmMain.Scan.Filtered := True;


What am i missing in this.???



Attachments: error.png
Sat, Dec 17 2022 5:43 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Peter


My guess would be some "forbidden" character that TEdit blocks but TLabel or user variable doesn't. Try comparing on a character by character basis and see.

Roy Lambert
Mon, Dec 19 2022 10:44 AMPermanent Link

Peter van Mierlo

EVENTSOFT

Avatar

Hi Roy,

Yep...there was a ENTER at the end of the scanned nfc-tag/barcode.
Problem is now solved using a additional Ttimer and code below.

procedure TFormContactScanManual.FormKeyPress(Sender: TObject; var Key: Char);
begin
   TimerMessage.Enabled := false; // reset interval

   if key= #13 then
   begin

      // Procedure for filtering databases
      ScanDataSearch;

      // Scan variabele leeg maken
      sSenderBARCODE := '';

   end
   else
     begin
          sSenderBARCODE      := sSenderBARCODE+Key;
     end;
    TimerKeyEmpty.Interval  := 500;
    TimerKeyEmpty.Enabled   := True;
end;

procedure TFormContactScanManual.TimerKeyEmptyTimer(Sender: TObject);
begin
   if sSenderBARCODE <> '' then // to long delay
 begin
    sSenderBARCODE   := ''; // als iets is gescanned zal dat onzin zijn
  end;
end;
Image