Open Query from Report

Hi Everybody

I design one report from Query with 3 variable :

- Starting Date

- Post Code

- Customer No

On Report I write code

Integer - OnPreDataItem()
  IF  (StartDate=0D) AND (PostCode='') THEN
    BEGIN
      Query_001.SETRANGE(Query_001.No,CustomerNo);
      Query_001.OPEN;
    END ELSE
  IF  (StartDate=0D) OR (CustomerNo='') THEN
    BEGIN
      Query_001.SETRANGE(Query_001.Post_Code,PostCode);
      Query_001.OPEN;
    END;
  IF  (StartDate <>0D) AND (CustomerNo='') AND (PostCode='') THEN BEGIN
       Query_001.SETRANGE(Query_001.Starting_Date,StartDate);
       Query_001.OPEN;
 END;

I do not understand why choosing Customer No and Post Code variables then activity statements, but when choosing the Starting Date variable the report is empty (no record exists).

Please help fix code. Thanks so much

Best Regards,

dinhson

  • And of course you already checked that your data actually contains records on that specific date?
  • In reply to Erik P. Ernst:

    Thanks for the reply.
    Make sure the startingdate values ​​are in my data table.
  • In reply to dinhson:

    hi dinhson,

    Maybe you should check this filter

    Query_001.SETRANGE(Query_001.Starting_Date,StartDate);

    >> using SETFILTER: Query_001.SETFILTER(Query_001.Starting_Date,'%1..', StartDate); 

     

    Thanks,

  • In reply to Hai:

    Thanks Hai reply. I have finished with function :

    IF  (StartDate=0D) THEN
    BEGIN
      IF  (StartDate=0D) AND (PostCode='') THEN
        BEGIN
          Query_001.SETRANGE(Query_001.No,CustomerNo);
          Query_001.OPEN;
        END ELSE
      IF  (StartDate=0D) OR (CustomerNo='') THEN
        BEGIN
          Query_001.SETRANGE(Query_001.Post_Code,PostCode);
          Query_001.OPEN;
        END;
    END ELSE
     IF  (StartDate <> 0D) THEN
          Query_001.SETFILTER(Query_001.Starting_Date,'%1',StartDate);
          Query_001.OPEN;
    

Related