Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2020 : Technical Questions
Message Icon Topic: How to align a field in Crystal through code Post Reply Post New Topic
Page  of 2 Next >>
Author Message
ehy01
Newbie
Newbie
Avatar

Joined: 29 Jan 2009
Location: Brazil
Online Status: Offline
Posts: 20
Quote ehy01 Replybullet Topic: How to align a field in Crystal through code
    Posted: 29 Jan 2009 at 12:40pm
I would like to align the data in a field depending on whether the field is numeric or not - but I cannot get the code to do it -
My pseudocode is (for Crystal)

if (ConditionA) then
   RightAlign
else
  leftAlign

How do I do it - I need the code
 
PLEASE!!!!Cry
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 29 Jan 2009 at 1:41pm
Right click on the field and select properties and select the Common Tab.
Next to the Horizontal Alignment click on the formula button. Your syntax options are in there but it would be something like:
If {table.field}=condition then crRightAligned else crLeftAligned
IP IP Logged
ehy01
Newbie
Newbie
Avatar

Joined: 29 Jan 2009
Location: Brazil
Online Status: Offline
Posts: 20
Quote ehy01 Replybullet Posted: 29 Jan 2009 at 1:46pm

Thx for answer, but what i want is:

If {table.field}=condition then
   {table.field_2} = crRightAligned
else
    {table.field_2} = crLeftAligned
 
get it?
 
Somethig like that, the condition in one field align another field.
 
Ps:Sorry, my English is terrible... ^^
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 29 Jan 2009 at 1:51pm
The process and formula are the same as i stated above but put the formula in your "field2" properties instead of "field1".
You can conditionally change one field's appearance based on any related field.
So, right click on field 2 (the one you want to change the text alignment) and insert the formula using field1 as your condition:
If {table.field}=condition then crRightAligned else crLeftAligned
IP IP Logged
ehy01
Newbie
Newbie
Avatar

Joined: 29 Jan 2009
Location: Brazil
Online Status: Offline
Posts: 20
Quote ehy01 Replybullet Posted: 29 Jan 2009 at 2:07pm
This is my formula:
If {F_RelConciliacaoAuto.tp_Dados} = "V" then
   crRightAligned
Else
   crLeftAligned
 
Work's great in normal field, but...
There's another problem, i have a Cross tab and i need align the Title of columns based on the first cell of the same column. In this case the formula did not work. What can i do?
 
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 29 Jan 2009 at 2:28pm
Hmmm. I have not had to use cross tabs very often but that is not an option to change text alignment there so you are out of luck.
Can you alter the report requirements to conditionally change some other characteristic like font color otr type? If so you can right click on the field and look at each of the different options. Wherever the conditiona formla is and is not greyed out you should be able to add a condition to change the field there.
IP IP Logged
ehy01
Newbie
Newbie
Avatar

Joined: 29 Jan 2009
Location: Brazil
Online Status: Offline
Posts: 20
Quote ehy01 Replybullet Posted: 29 Jan 2009 at 4:25pm
Yeah, the place to input the conditional formula on the title of column is there, the problem is the formula isnt work.
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 29 Jan 2009 at 8:16pm
Sorry but I am not sure what the condition is that needs to be met for your alignment to switch.
Anyone else have any thoughts with a crosstab field?
IP IP Logged
ehy01
Newbie
Newbie
Avatar

Joined: 29 Jan 2009
Location: Brazil
Online Status: Offline
Posts: 20
Quote ehy01 Replybullet Posted: 30 Jan 2009 at 2:55am
Thanks DBlank!!!
 
Anyone else?
 
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 30 Jan 2009 at 9:37am
One more thing you can try.
Click on the field that you are trying to change the text from. The field name will appear int he lower left hand corner of your crystal screen. Use that as a reference to know what field you are conditionally using and then put it into the formula.
Not sure it will work but it is worth a try.
IP IP Logged
Page  of 2 Next >>
Post Reply Post New Topic
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



This page was generated in 0.016 seconds.