mlcktmguy
asked on
How to Suppress field at runtime
I am running Crystal 11.0 reports from a VB 6.0 application. I have standard headers and footers on all reports. I am using code to change contents of fields at runtime. Here is an example of wha I am now doing:
With passedReport.Sections("Pag eFooterSec tion1")
.ReportObjects.Item("genCo ntractName ").SetText rptContractName
.ReportObjects.Item("genSi teName").S etText rptSiteName
End With
The user has requested the option of suppressing specified fields at their discretion. I suspect this is similarto what I am doing now but I can't find any documentation on what the property would be instead of 'SetText'. Is it something like:
With passedReport.Sections("Pag eFooterSec tion1")
.ReportObjects.Item("genCo ntractName ").Supress True
.ReportObjects.Item("genSi teName").S uppress True
End With
With passedReport.Sections("Pag
.ReportObjects.Item("genCo
.ReportObjects.Item("genSi
End With
The user has requested the option of suppressing specified fields at their discretion. I suspect this is similarto what I am doing now but I can't find any documentation on what the property would be instead of 'SetText'. Is it something like:
With passedReport.Sections("Pag
.ReportObjects.Item("genCo
.ReportObjects.Item("genSi
End With
ASKER
Thanks for your interest. Over the last week you have helped me out on several Crystal related issues. I have tried these:
.ReportObjects.Item("lblPa ge").Suppr ess = True
.ReportObjects.Item("lblPa ge").Visib le = True
.ReportObjects.Item("lblPa ge").Suppr ess True
all three give me 'object doesn't support this property or method.
However, I have gotten further. Based on another EE post I tried:
Dim strFormulaName As String
Dim crSection As CRAXDRT.Section
Dim crxFieldObj As CRAXDRT.FieldObject
Dim i As Integer
For Each crSection In passedReport.Sections
For i = 1 To crSection.ReportObjects.Co unt
If crSection.ReportObjects(i) .Kind = crFieldObject Then
Set crxFieldObj = crSection.ReportObjects(i)
' If crxFieldObj.Field.Name = strFormulaName Then
crxFieldObj.Suppress = True
crxFieldObj.BackColor = vbYellow
' End If
End If
Next i
Next
This sort of works. I first tried it only setting the fields to yellow with the if statment commented. It changed many (but not all) of the fields on the report to yellow. As it is now above I have the if statement which would only make this work on specific fields, commented. When I run it as is, it looks like it supresses all of the bound or parameter fields on the report but no labels. There are two problems. I need to suppress only specific fields on the report. They are not bound fields and a couple are labels. When I uncomment the if statement and replace strFormulaName with "lblPage" which is the name one of the labels that I want to suppress, nothing is suppressed or yellow. When I show crxFieldObj.Field.Name as I go through the loop it contains a null string. This is all new to me and I can find no documentation on the properties in this example. All of the Crystal documentation is geared towards creating reports in the Crystal development environment.
I'd really appreciate any input or even explanation on why the back color on all the fields are not turned yellow, just most of them.
I'm going to bump the point to 250.
.ReportObjects.Item("lblPa
.ReportObjects.Item("lblPa
.ReportObjects.Item("lblPa
all three give me 'object doesn't support this property or method.
However, I have gotten further. Based on another EE post I tried:
Dim strFormulaName As String
Dim crSection As CRAXDRT.Section
Dim crxFieldObj As CRAXDRT.FieldObject
Dim i As Integer
For Each crSection In passedReport.Sections
For i = 1 To crSection.ReportObjects.Co
If crSection.ReportObjects(i)
Set crxFieldObj = crSection.ReportObjects(i)
' If crxFieldObj.Field.Name = strFormulaName Then
crxFieldObj.Suppress = True
crxFieldObj.BackColor = vbYellow
' End If
End If
Next i
Next
This sort of works. I first tried it only setting the fields to yellow with the if statment commented. It changed many (but not all) of the fields on the report to yellow. As it is now above I have the if statement which would only make this work on specific fields, commented. When I run it as is, it looks like it supresses all of the bound or parameter fields on the report but no labels. There are two problems. I need to suppress only specific fields on the report. They are not bound fields and a couple are labels. When I uncomment the if statement and replace strFormulaName with "lblPage" which is the name one of the labels that I want to suppress, nothing is suppressed or yellow. When I show crxFieldObj.Field.Name as I go through the loop it contains a null string. This is all new to me and I can find no documentation on the properties in this example. All of the Crystal documentation is geared towards creating reports in the Crystal development environment.
I'd really appreciate any input or even explanation on why the back color on all the fields are not turned yellow, just most of them.
I'm going to bump the point to 250.
HOw many fields are there?
One way to do it for sure is to use conditional suppression on the field and pass in a parameter for each field. This is plausible if there are maybe 10 or so fields. WIth much more than 10 the formulas and parameters become tough to handle.
mlmcc
One way to do it for sure is to use conditional suppression on the field and pass in a parameter for each field. This is plausible if there are maybe 10 or so fields. WIth much more than 10 the formulas and parameters become tough to handle.
mlmcc
ASKER
I have standard headers and footers on all of the reports. There are five fiedls on each report times 15 reports.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I use Crystal 9 but these should be much the same.
Constants for CRObjectKind...
crFieldObject
crTextObject
crLineObject
crBoxObject
crSubreportObject
crOleObject
crGraphObject
crCrossTabObject
crBlobFieldObject
crMapObject
crOlapGridObject
Constants for CRObjectKind...
crFieldObject
crTextObject
crLineObject
crBoxObject
crSubreportObject
crOleObject
crGraphObject
crCrossTabObject
crBlobFieldObject
crMapObject
crOlapGridObject
Another thought I just had...
I think (I would have to check code to verify) that for crxFieldObject.Field.Name or crxTextObject.Field.Name it actually returns the name as "lblPage1".
The 1 being the section that the object belongs too. So you would need to check for that.
But as I said, dont quote me on this one.
I think (I would have to check code to verify) that for crxFieldObject.Field.Name or crxTextObject.Field.Name it actually returns the name as "lblPage1".
The 1 being the section that the object belongs too. So you would need to check for that.
But as I said, dont quote me on this one.
Oh no.. I remember now!!
Please disregard the last post.
The 1 is just default naming given to objects.
Say if you have a field called MyField, if you drop this onto a report it is given a default name of MyField1.
If you drop the same field onto the report again it would be called MyField2.
This tripped me up when I first starting trying to find objects, I kept looking for "MyField" when it was really called "MyField1".
Sorry about that.
Please disregard the last post.
The 1 is just default naming given to objects.
Say if you have a field called MyField, if you drop this onto a report it is given a default name of MyField1.
If you drop the same field onto the report again it would be called MyField2.
This tripped me up when I first starting trying to find objects, I kept looking for "MyField" when it was really called "MyField1".
Sorry about that.
ASKER
Thanks so much, I get it now.
No problem. Glad to help.
Thanks.
Thanks.
.ReportObjects.Item("genCo
or maybe use Visible
mlmcc