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

What am I doing wrong here?

edited July 2006 in End User

Hi Guys,

I have a report in Report Explorer called Invoice. In its SQL the 'where'
clause looks for Invnumb = 40460. All works OK.

I am now trying to load the report, set the Invnumb to 116910 and then print
it using the following code snippets.

==========================================
procedure TmyEndUserSolution.Button1Click(Sender: TObject);
begin
ppReportExplorer1.LoadReport('Invoice',6);
ppreport1.ShowAutoSearchDialog := False;
ppReport1.Print;
end;

procedure TmyEndUserSolution.ppReport1GetAutoSearchValues(Sender: TObject);
begin
if (ppReport1.AutoSearchFieldCount = 0) then Exit;
if (ppReport1.AutoSearchFields[0].FieldName = 'Invnumb') then
ppReport1.AutoSearchFields[0].SearchExpression := '116910';
end;
============================================

It loads and prints the report OK but shows the Invoice as 40460 not 116910 as
required.

What have I missed???

Invnumb is a numeric field. Is this the issue? If so how do I get around it?

Regards & TIA,

Ian



--

Comments

  • edited July 2006
    Sorry. Using D7 Pro & latest RBuilder.



    --
  • edited July 2006
    AFAIKS there is nothing in the help/documentation to say so but the Field Name
    needed to be in Upper Case, the same as defined in the database.

    So..
    if (ppReport1.AutoSearchFields[0].FieldName = 'Invnumb') then
    ppReport1.AutoSearchFields[0].SearchExpression := '116910';

    Became..
    if (ppReport1.AutoSearchFields[0].FieldName = 'INVNUMB') then
    ppReport1.AutoSearchFields[0].SearchExpression := '116910';

    and it all worked as expected..

    I presume therefore that if the field name in the database was 'Invnumb' rather
    than 'INVNUMB' then my original effort would have worked.

    Don't know if this is specific to my database, DBISAM, or generic.

    Regards,

    Ian
    --
  • edited July 2006

    This is a Delphi language behavior, the = operator performs a case sensitive
    comparision of two strings.

    Try this example in a button OnClick event...

    if ('Invnumb' = 'INVNUMB') then
    ShowMessage('Using the = operator is a case-sensitive comparison');


    if CompareText('Invnumb' = 'INVNUMB') = 0 then
    ShowMessage('Using the CompareText function is a non case-sensitive
    comparison');



    --
    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com

    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
  • edited August 2006
    Nard Moseley (Digital Metaphors) wrote:


    Hi Nard,

    Well what do you know. I have not come up against that issue in all my Delphi
    time. Learn something new every day..

    Regards & thanks for the insight.

    Ian

    --
This discussion has been closed.