Crystal Report function-pls help

  • Thread starter Kapil Shah via DotNetMonster.com
  • Start date
K

Kapil Shah via DotNetMonster.com

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
 
G

Guest

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,763
Messages
2,569,562
Members
45,038
Latest member
OrderProperKetocapsules

Latest Threads

Top