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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Assign number of characters to a field

Status
Not open for further replies.

hstandley

MIS
Mar 31, 2004
8
US
Good afternoon folks.

I am using Crystal XI and I need to assign character spaces to columns. In orther words I want to make sure that a field will have enough space to hold up to the number of spaces assigned to it.

Thanks,
Harry
 
Sounds like you want to pad a field with spaces.

Here's an example:

{table.field}+repeatstring(" ",20-len({table.field}))

Replace 20 with the length you want for the field.

Numerics and dates will need to be converted using totext(), but the same theory applies.

-k
 
Thanks for your reply.

This is what I am using:

ToText({P_DAILY_SALES_EDIT.WEIGHT})+repeatstring(" ",20-len(totext({P_DAILY_SALES_EDIT.WEIGHT})))

This does not seems to work, where did I go wrong here?
Harry
 
I did some more searching and I found this:

If Length(ToText({P_DAILY_SALES_EDIT.WEIGHT})) < 15 then

toText({P_DAILY_SALES_EDIT.WEIGHT}) + Space (14 - length(ToText({P_DAILY_SALES_EDIT.WEIGHT}))) + Chr(13)

else

ToText({P_DAILY_SALES_EDIT.WEIGHT})

This seems to work.

Thanks for your help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top