Home RAP
New Blog Posts: Merging Reports - Part 1 and Part 2

Custom Label for between search

edited July 2004 in RAP
Hello,



I am using RB 7.02 and I am trying to format a label to print the results of
a between search. I setup the following code:



var

PosBetween: integer;

HoldValue, RemainingValue, NewCaption, AllValue : string;

begin

if Report.AutoSearchFieldCount > 0 then begin

HoldValue := Report.AutoSearchDescription;

NewCaption := ' Date Range: ';

PosBetween := Pos('between', HoldValue);

RemainingValue := Copy(HoldValue, PosBetween + 7, Length(HoldValue));

Label1.Caption := NewCaption + RemainingValue;

end

else begin

AllValue:= ' All Dates ';

Label1.Caption := AllValue;

end;

end;



The above works well when there is data in the AutoSearch field, but if it
is blank, I get a Date Range: label instead of the intended All Dates label.



I also tried changing the lines after else begin to only one line:



Label1.Visible := false;



This does not work either. I am wondering what I am doing wrong?



I also would like to be a little bit more creative with the above and have
the label print the beginning and ending dates separatedly, something like:



From: (date) to (date).



Can this be done or am I asking for much?



Thanks in advance for your help.



Mark.

Comments

  • edited July 2004

    Try something like this:

    uses
    ppReport, ppASField;

    var
    lAutoSearchField: TppAutoSearchField;

    begin

    lAutoSearchField := ppReport1.AutoSearchFields[0];


    if (lAutoSearchField.ShowAllValues) then
    ppLabel1.Caption := 'All Dates'
    else
    ppLabel1.Caption := 'From ' + DateToStr(lAutoSearchField.Values[0]) + '
    to ' + DateToStr(lAutoSearchField.Values[1]);

    end;


    --


    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
This discussion has been closed.