Author |
Message |
ehy01
Newbie
Joined: 29 Jan 2009
Location: Brazil
Online Status: Offline
Posts: 20
|
 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!!!!
|
IP Logged |
|
DBlank
Moderator
Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
|
 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 Logged |
|
ehy01
Newbie
Joined: 29 Jan 2009
Location: Brazil
Online Status: Offline
Posts: 20
|
 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 Logged |
|
DBlank
Moderator
Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
|
 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 Logged |
|
ehy01
Newbie
Joined: 29 Jan 2009
Location: Brazil
Online Status: Offline
Posts: 20
|
 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 Logged |
|
DBlank
Moderator
Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
|
 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 Logged |
|
ehy01
Newbie
Joined: 29 Jan 2009
Location: Brazil
Online Status: Offline
Posts: 20
|
 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 Logged |
|
DBlank
Moderator
Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
|
 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 Logged |
|
ehy01
Newbie
Joined: 29 Jan 2009
Location: Brazil
Online Status: Offline
Posts: 20
|
 Posted: 30 Jan 2009 at 2:55am |
Thanks DBlank!!!
Anyone else?
|
IP Logged |
|
DBlank
Moderator
Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
|
 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 Logged |
|
|