Groups | Blog | Home
all groups > asp.net > february 2005 >

asp.net : Crystal Report function-pls help


Kapil Shah via DotNetMonster.com
2/24/2005 8:56:59 PM
Hello Everybody,
I am trying to write a crystal report function which should return a value
of 1 for crystal report with no parameter and return a value 2 for crystal
report with parameter.

Public Function LoadReport(ByVal reportname As String, ByRef patable As
System.Web.UI.WebControls.Table) As Integer

Doccr = New CrystalDecisions.CrystalReports.Engine.ReportDocum ent '
instantiate a report document

Doccr.Load(reportname) ' load the report whose name you were given
Dim value As Integer = 0

If Doccr.IsLoaded Then


Dim crParamFieldDefinitions As
CrystalDecisions.CrystalReports.Engine.ParameterFi eldDefinitions =
Doccr.DataDefinition.ParameterFields

If crParamFieldDefinitions.Count < 1 Then 'if no params,
Return value = 1
End if

If crParamFieldDefinitions.Count > 1 Then ' with parameter
return value=2
End if

End if ' End of Doccr.IsLoaded

End Function


For some reason when I click the crystal report button with no parameter I
get the value as 0 (should return 1)and also when I click the crystal
report button with parameter I get the value as 0. (should return 2)


Would be greatful if someone helps with this function..

Rahil

--
Chris Podmore
2/25/2005 1:27:01 AM
Rahil,

There are a couple of problems with your function.

First you are returning "Return value = 1", isn't this doing a compare of
value being equal to 1, this will always return 0 (False) as value is equal
to 0. Try putting it on two lines:
value = 1
Return value

The other problem is if there is only one parameter on the report you will
also get zero. The "If crParamFieldDefinitions.Count > 1 Then ' with
parameter" line should read ">=".

Hope this helps.
Chris.


[quoted text, click to view]
AddThis Social Bookmark Button