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

Dynamic Field Placement

Status
Not open for further replies.

Bchemist

Programmer
Apr 3, 2002
91
0
0
US
First let me say that I am new to crystal so this may be simple it may not be but I am unsure how to do it and can't find any threads that seem to apply to this.

I need to dynamically adjust the placement of a multiline field at run time based upon the value of another field. Another words if field a = 1 then field b's left property should be 360, if field a = 2 then field b's left property should be set to 720, etc

I am accustomed to using MS Access reports and there it would be quite simple, something to the effect of

Code:
FieldB.Left = FieldA * 360

however I have not found where something to that effect can be performed in Crystal. I have been able to perform something similar for single line items by inserting blank spaces and concatinating a database field to a formula field. But since these are multiple line fields this only indents the first line, and not the following lines. I have also tried to use the hierarchical grouping options but have not been able to get this to work right (could be my lack of knowledge)

Any ideas would be helpful. Oh yeah, I am using Crystal Decisions for .NET with VS .NET 2003
 
here is a sample code in vb.net for placing fields at runtime.

In vb similar method is there ( Some class name may differ).
For This u have to use RDC(Report component designer) rather than crystal report control in VB

Dim objfld As CrystalDecisions.CrystalReports.Engine.FieldObject
Dim objSCTN As CrystalDecisions.CrystalReports.Engine.Section
Dim objRPTOBJ As CrystalDecisions.CrystalReports.Engine.ReportObject
Dim objRpt As New CrystalReport1
For Each objSCTN In objRpt.Section1.ReportObjects()
For Each objRPTOBJ In objSCTN.ReportObjects
If objRPTOBJ.Kind = CrystalDecisions.CrystalReports.Engine.FieldObject Then
objfld = objRPTOBJ
If objfld.Name = "abc" Then
objfld.Left = 1000
End If
End If
Next
Next
 
rana77 Thanks for the repy, unfortunately I obviously didn't clarify what I needed. I need fieldb to be placed dependant upon the value of fielda, which could be different for each record. Something like this

[tt]
FieldA FieldB
1 sample text
1 sample text
2 sample text
3 sample text
1 sample text
2 sample text
2 sample text
4 sample text
3 sample text
[/tt]

basicaly like the hierarchical grouping option, but variable spacing and the text will more often than not be multiple lines so I can't just insert spaces.
 
You could get the effect by placing the text field several times and then suppressing all but one of them, based on your formula. Right-click on the detail section and choose Format Section. Then choose the formula icon (x+2 and a pencil) for suppression. Enter a formula; e.g.
FieldB.Left <> FieldA * 360

You might also be able to display the text with leading spaces, e.g.
if FieldB.Left = FieldA * 360
then " " & {sample text}
else " " & {sample text}


[yinyang] Madawc Williams (East Anglia, UK) [yinyang]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top