Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Developing a Crystal Report in text format

Status
Not open for further replies.

DSenger

Vendor
Oct 29, 2019
10
0
0
US
HI
I am developing a Crystal Report in text format but my columns are not aligning as to the number of spaces that are to be in each field, such as the last name field is to be 13 space field size, first name is to be 10 space field size, etc.

I have this as one of the formulas:
stringvar padSpaces:=space(250)

The following is the formula I have for each of the field names. When I try to save this formula, it is stating that the ,13)is an error in the formula. Any suggestions?

stringvar myString:="";


mystring:=
left({OFFENDERS.LAST_NAME}+{@spaces}),13)
 
I just recreated your formulas and they worked fine. I think you might have a null in your name field, as unlikely as that may sound (maybe someone entered the first and last name in the same field?). Try the following:

stringvar myString := "";
stringvar lname := "";
if isnull({OFFENDERS.LAST_NAME)) then
lname := "" else
lname := {OFFENDERS.LAST_NAME);
myString := left(lname+{@spaces}, 13);

-LB
 
Thank you!! The formula now works but my columns are still not aligning. Any suggestions?
 
Make sure you are using a font like Courier New that is non-proportional.

-LB
 
Thanks - that worked perfectly BUT when I go to export in text, the columns are not aligned.
 
That’s a little hard to troubleshoot without more info. Try attaching your fields to each other in design mode so that they share the same grid lines. When they are attached properly, the corners will turn red. Then right click on the detail section->select all objects->right click on one of the fields->make same size->height. Then right click again->align->to baseline. Then click on the details section->fit section. Then export.

-LB
 
Thanks - After I wrote the formula, my next step directions were to take the formulas and place them in a text box - one after another. With this, it lines up one after another, when I generate it, like below, which is correct.

00000000000000 0000000(13sp) 000000(10sp)0000000000000000000000000000000000000000
00000000000000 0000000(13sp) 000000(10sp)0000000000000000000000000000000000000000
00000000000000 0000000(13sp) 000000(10sp)0000000000000000000000000000000000000000

When I took the formulas out of that text box to export it to a text format, the data does not line up correctly - also when I export it from the correct format in Crystal Reports to a text format, it comes out like this example rather than the 1st example above.

00000000000000 0000000 0000000 000 0000000000000000000000
00000000000000 0000000 00000 000 0000000000000000000
00000000000000 0000 00000 000 00000000000000000000000000

I am confused as to why when I export it to a text file that it messes up everything (looks like the second example) instead of like the 1st example. I thank you so much for your time. I have been working on this for weeks to no avail but am getting some ground thanks to you.
 
I’m not sure. I’m confused by the differing numbers of zeros when comparing rows in your second example.

Have you tried exporting to different text formats? Tab-separated text, csv, text?

-LB
 
I have a report where I export to text and the columns are fixed length. The basic formula for each column looks something like this.

if isnull({PS_TC_CPAS_DETAIL.MAILING_CITY})= yes
then space(30)
else {PS_TC_CPAS_DETAIL.MAILING_CITY}& space(30-length({PS_TC_CPAS_DETAIL.MAILING_CITY}))

I hope this helps.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top