• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1043
  • Last Modified:

Concatenate QuickReport Data

Hi

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
0
whythetorment
Asked:
whythetorment
1 Solution
 
kretzschmarCommented:
try

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 ;-)
0
 
dygjCommented:
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
0
 
TheRealLokiSenior DeveloperCommented:
add a "calculated" field to your query's fielddefs
i.e.
double click on your query.
"add" "new field"
"FullName"
string 128
calculated

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
0
 
whythetormentAuthor Commented:
*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....
0

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Tackle projects and never again get stuck behind a technical roadblock.
Join Now