Vb.net Running crystal reports issue - differing output

  • Thread starter Thread starter Rob W
  • Start date Start date
R

Rob W

Greetings,

My crystal report consists of the following important fields:-

*Sort field
*Group field name (boolean field, which I display a count on the footer,
therefore should only print TWICE)
*Parameter (number used to determine the record selection)

When running/previewing within the IDE and typing in the parameter it works
fine and displays my data as expected.

However when passing in the sort field and the parameter which is used for
the record selection criteria into crystal report file/report viewer from my
application, it affects the group field footer.

It now appears after every single record, as if the new group field has
become the unique record id (member id) rather than a deceased field
(boolean) which should group the report into TWO halves as set in the report
file.

It has confused me as the parameters being passed through are not related to
the group field in my vb.net code.

I was looking into programmatically setting the group field in vb.net but
looking at the class structure I don't think it can be set.

So to summarise the group field a boolean was expected to print a count in
the footer TWICE. Now the group footer is displayed after every single
record when run using the app and NOT when using the crystal reports IDE.

The only difference between me running the report through the application is
that I pass in a sort order.

Has anyone experienced a similar issue?
Any ideas how to resolve it and/or further debug?

Thanks
Rob
 
Better explanation with more debugging and code example:-


My crystal report has a group name field (boolean) and a sort selection
field (membership id).

This generates the following sql (via database -> show sql)

Code:
SELECT `Members`.`cMembershipId`, `Members`.`cTitle`, `Members`.`CSurname`,
`Members`.`CforeNames`, `Members`.`cWRorBranch`,
`Members`.`cDateLastVisited`, `Members`.`cHouseNum`,
`Members`.`cAddressLine1`, `Members`.`cAddressLine2`, `Members`.`cTown`,
`Members`.`cCity`, `Members`.`cCounty`, `Members`.`cPostcode`,
`Members`.`cTelephone`, `Members`.`cMobile`, `Members`.`cDeceased`
FROM `Members` `Members`
ORDER BY `Members`.`cDeceased`, `Members`.`cMembershipId`Somewhat suprised
as their is no GROUP BY clause within the SQL.

However the results are as expected with the report being grouped into TWO
halves since the group name field is a boolean.

I previously had my application running the report passing in a sort field
value into my report, which at the time had no group name field.

Programming the sort code via vb.net code worked without issues.

I then added the group name field into the crystal report.
Then when running the report the group name field ALWAYS was set to the sort
field rather than the deceased value as set in the .rpt file.

Even though the code did not access the group field.

Code:
'Assign field name to field defination
FieldDef = cryRpt.Database.Tables.Item(0).Fields.Item("cMembershipId")
cryRpt.DataDefinition.SortFields.Item(0).Field = FieldDefI then debugged
further by programmatically setting the group name field:-


Code:
Dim grpline As FieldDefinition
grpline = cryRpt.Database.Tables(0).Fields("cDeceased")
cryRpt.DataDefinition.Groups.Item(0).ConditionField = grpline

'Assign field name to field defination
FieldDef = cryRpt.Database.Tables.Item(0).Fields.Item("cMembershipId")
cryRpt.DataDefinition.SortFields.Item(0).Field = FieldDefalso experimented
with the Database option -> peform grouping on server.

What is the way forward to ensure the report is grouped by the cDeceased
field and then sorted by a choice of other fields base on the value of a
radio button (this code is in place, an example of setting the sortfield is
included in this post).

Any advice and help would be really appreaciated.

Thanks
Rob
 
Back
Top