Concatenate QuickReport Data

Posted on 2005-05-03
Last Modified: 2013-11-22

How do you concatenate QRDBText data on a report?  E.g. I have a customer firstname and lastname fields.  On my report i just want them as "ABC DEF".  Dont wanna use two QRDBTexts coz it doesnt look nice and dont know long each fields will be.  Ive tried an expression e.g. QueryConfirmation.FirstName + ' ' + QueryConfirmation.LastName.  But when it ran it just said unknown function.

Im using Delphi 5 and quickreport 3.

Thanx for any help
Question by:whythetorment
    LVL 27

    Expert Comment


    QueryConfirmation.FirstName.AsStrting + ' ' + QueryConfirmation.LastName.AsString

    just from head

    you can also concat the fields within your query like

    select firstname||' '||lastname as fullname from yourtable

    select-syntax depends on the db you use

    meikl ;-)
    LVL 3

    Accepted Solution

    if you are using a qrexpr you can set the the expression to
    query1.firstname+' '+query1.lastname

    if you are using a  qrlabel
    - you can  set the caption in the beforeprint event for the band the label is printed on
    myqyrlabel1.caption:=query1.fieldbyname('firstname').asstring+' '+query1.fieldbyname('lastname').asstring

    - or you can set the  value in onprint event for the label.
    value:=query1.fieldbyname('firstname').asstring+' '+query1.fieldbyname('lastname').asstring

    Or you can return both fields from the sql.
    In ms access it would be: select firstname+' '+lastname from name..

    Bjarte Dyngjeland
    LVL 17

    Expert Comment

    add a "calculated" field to your query's fielddefs
    double click on your query.
    "add" "new field"
    string 128

    then in your query's OnCalcFields event simply do
    dataset.FieldByName('FullName').AsString := dataset.FieldByName('FirstName').AsString + ' ' + dataset.FieldByName('LastName').AsString

    then in the quickreport, all you need to do is set the datafield as "FullName"
    this way you could also group by FullName etc, or use it in other situations

    Author Comment

    *you can  set the caption in the beforeprint event for the band the label is printed on
    myqyrlabel1.caption:=query1.fieldbyname('firstname').asstring+' '+query1.fieldbyname('lastname').asstring*

    worked fine....

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
    In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
    how to add IIS SMTP to handle application/Scanner relays into office 365.
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

    734 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now