Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: DYNAMICALLY REPOSTION FIELDS Post Reply Post New Topic
Author Message
slimshady
Newbie
Newbie
Avatar

Joined: 22 Feb 2009
Location: Kenya
Online Status: Offline
Posts: 3
Quote slimshady Replybullet Topic: DYNAMICALLY REPOSTION FIELDS
     Posted: 22 Feb 2009 at 11:48pm
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: 23 Feb 2009 at 12:23am
HI
 
Create  formulas for Label and Amount Field
 
Frm_Label
If Condition  = 0 then
"Consecutive Label"
Else
"Label"
 
Frm_Amount
If Condition = 0 then
Consecutive Amount
else
Amount
 
Place them in the report accordingly
 
Cheers
Rahul
 
IP IP Logged
slimshady
Newbie
Newbie
Avatar

Joined: 22 Feb 2009
Location: Kenya
Online Status: Offline
Posts: 3
Quote slimshady Replybullet Posted: 23 Feb 2009 at 1:04am
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 23 Feb 2009 at 6:39am
I have done something similar, in Crystal XI, you can position the labels/fields via the Size and Position.  In the formula, the change is always in some measurement that is 1440 (I think) to the inch, and here is the important part, the change is always from where the label is NOT THE ABSOLUTE LOCATION ON THE REPORT...that took forever to realize.
 
So what I think you need to do is to create a function or a formula that will a) store the 'current' end of the line, b) update this value as needed, c) increment correctly...
The field is 0, do nothing, supress the label/field.  The field is not 0, position the label/field at the 'current' end of line, take the length of the label/field (plus the separation distance) and add it to the end of the line position.
 
when all of this works, take all 40+ fields/labels and put them at basically 0,0 for their band, this way the 'current' end field is just the distance from the left hand margin of the report to the start of the label/field.
 
Boy, I hope that this made sense.  It is a bit of a pain to do, but when it works, it seems amazing, as it gives great flexiblity, but is a total pain to maintain as all of the fields appear in the designer as one big blob.
 
Hope this helps
IP IP Logged
slimshady
Newbie
Newbie
Avatar

Joined: 22 Feb 2009
Location: Kenya
Online Status: Offline
Posts: 3
Quote slimshady Replybullet Posted: 24 Feb 2009 at 4:22am
lockwelle i appreciate your input to my problem, however i haven't quite understood your formula. I have tried to look up for what you have refered here, unfortunatelly, didn't get it.

Thanks though.

as a stop gap measure, I have suppressed all  < = 0 fields.  Meaning that if an employee is not making any contribution the filed together with the label is suppressed. However, this is making the whole report to appear untidy and disorganized. Items thrown all over.
More input appreciated.
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 24 Feb 2009 at 6:33am
Let's see I can explain it a different way...
Are you using CR XI?  I don't believe that the option is available before this version.
 
when you right click on a field one of the options around Insert and Move is 'Size and Position'.  If you click on this, there is the option for X/Y and Width Height.  You will notice that there is the function button 'X-2' next to X and width, since you are looking to move the fields, I will ignore the Width.  If you wrote a formula based on a value for that value in the field, let's say if it is 0, move it to the right (just for example) by 1 inch.
 
So let's say your formula inside the x-2 button looks like:
if {field}=0 then 1 //this won't have moved by 1 inch as we assumed it would...but:
if {field}=0 then 1440 // this will move it by the inch that we wanted.
 
with this info, we can write a Report Custom Function which would take the value of the field, the width and a distance as arguements...something like: (let's say we called the function ShiftRight)
if {field}>0 then MoveRight + CellWidth*1440 + (.125*1440)
  //this will return the value of the where the next cell should start.
 
it the 'x-2' button for the cell we want to move we might have something like;
shared numbervar AmountToMoveRight; 
local numbervar tempMove := AmountToMoveRight; //this is where the cell should print
 
AmountToMoveRight := ShiftRight({field}, .65, AmountToMoveRight);
tempMove
 
the .65 is the size as reported in the SizePosition width value
 
this should shift the cells.  You will still need to suppress the unwanted cells, and since the value is how much you will move the cell, not where the cell will end up (seems silly but that is how it works), all of the cells that you want to shift need to start in same spot...but experimentation will demonstrate this.
 
Last thing, you will need to set AmountToShiftRight to 0 at the start of each line.  If there is a field that will always be shown, say name, I would put its x-2 button for X the reset command of:Shared Numbervar AmountToShiftRight :=0
 
Hope this is more helpful...or you might try to Google 'Size and Position' for Crystal Reports.
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