Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Design format Post Reply Post New Topic
Author Message
kenny_gua1
Newbie
Newbie


Joined: 19 Dec 2008
Location: Canada
Online Status: Offline
Posts: 2
Quote kenny_gua1 Replybullet Topic: Design format
     Posted: 19 Dec 2008 at 9:53pm
HI,
I am new in crystal report designing.
I have three field in SQL-database. Empid (10 characters length), surname (20 characters length) and third is SIN (9 characters length).
 
I have  following data in database
Empid            Surname        SIN
1002             Stephan        7121118999
20022           Allan              7132344564
145666         Robert           7138823883
 
 
How can I design the crystal report for the desired format using the above data.
 
Desired format in crystal report
00001002Stephan                      7121118999
00020022Allan                            7132344564
00145666Robert                         7138823883
 
//I dont want to display Field-Heading in output
//Empid shoud be in 8 characters, if characters are short then add 'Zero' in starting.
// Surname field should start from 9th column.
//SIN field-data should start from 29th column.
 
Please help in design the above report.
Thanks.
 
IP IP Logged
rahulwalawalkar
Senior Member
Senior Member
Avatar

Joined: 08 Jun 2007
Location: United Kingdom
Online Status: Offline
Posts: 731
Quote rahulwalawalkar Replybullet Posted: 20 Dec 2008 at 1:22am
Hi
Use the sql below and then create view or use command object
 
select
empid,
surname,
sin ,

--the below code adds leading zeros depending on length of the field
stuff(empid, 1, 0, replicate('0', 8 - len(empid)))+surname as 'Empid-Surname',

-- starts the sin from 29th position
stuff(sin, 1, 0, replicate(' ', 29 - len(sin))) as 'Sin',

---final result
stuff(empid, 1, 0, replicate('0', 8 - len(empid)))+surname+
stuff(sin, 1, 0, replicate(' ', 29 - len(stuff(empid, 1, 0, replicate('0', 8 - len(empid)))+surname)))AS Result

from Table_Emp
 
the final result is not formatted correctly due to lenght of values in surname field ......hope you can work on it..........
 
cheers
Rahul
 
IP IP Logged
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum