Print Page | Close Window

VB6 To .Net Report Conversion

Printed From: Crystal Reports Book
Category: Crystal Reports for Visual Studio 2005 and Newer
Forum Name: Writing Code
Forum Discription: .NET programming API, report integration
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=1608
Printed Date: 20 Sep 2024 at 2:53pm


Topic: VB6 To .Net Report Conversion
Posted By: skyinsdevel
Subject: VB6 To .Net Report Conversion
Date Posted: 01 Nov 2007 at 1:34pm

Thank you for any help provided in advance.

Specs:
Database: Access
Crystal Reports: Version 9 Developer Licence with VS.net I believe it is Upgrade
IDE: Visual Studio 2005
 
Ok, I got this project that is done in VB6 there are about 6 reports or more.  That programmer used code to modify his reports at RunTime. He has used code like this:

STARTCODE: (Don't know the tag)

Report1.SelectionFormula = " mailto:%7b@ActivityDate - {@ActivityDate } >= " & CryDateFrom & " AND " & " mailto:%7b@ActivityDate - {@ActivityDate } <= " & CryDateTo
If optSortbyDate.Value = True Then
    Report1.GroupCondition(0) = "GROUP1;{@ActivityDate};DAILY;A"
    Report1.SortFields(0) = " mailto:+%7b@ActivityDate - +{@ActivityDate }"
    Report1.SortFields(1) = "+{ActivityLog.Id}"
ElseIf optSortbyUser.Value = True Then
    Report1.GroupCondition(0) = "GROUP1;{ActivityLog.UserId};ANYCHANGE;A"
    Report1.SortFields(0) = "+{ActivityLog.UserId}"
    Report1.SortFields(1) = "+{ActivityLog.Id}"
ElseIf optSortbyNetw.Value = True Then
    Report1.GroupCondition(0) = "GROUP1;{ActivityLog.NetwUser};ANYCHANGE;A"
    Report1.SortFields(0) = "+{ActivityLog.NetwUser}"
    Report1.SortFields(1) = "+{ActivityLog.Id}"
End If
 
ENDCODE:
 
I managed to do three things. One change the database connection:

ReportCls.DataSourceConnections.Item(0).SetConnection("", mdbFileName, False)

Second, change a string in a formula field:
ReportCls.DataDefinition.FormulaFields.Item("Period").Text = """From StartingDate to Ending Date yadayada"""
 
Third, Change the selection formula.
ReportCls.DataDefinition.RecordSelectionFormula = "{@ActivityDate} >= " & "DTSToDate ('2007/1/1')" & " AND " & "{@ActivityDate} <= " & "DTSToDate ('2007/12/12')"
 
The problem lies with the grouping part. There is a set of 3 radiobuttons that specify how is the grouping to be done. I have looked through the ReportClass to no avail on how to change it. 
 
I got about 5-8 more of these, do you also think I should quit? Again thanks for the help.
 



Replies:
Posted By: ultraspxse
Date Posted: 05 Nov 2007 at 8:51am
I don't have a specific solution but have you researched differences between the Crystal runtime engine used to develop the reports originally (assuming version 9) and the runtime for Visual Studio 2005 (10.2.3600.0).
 
I assume your converting the VB6 code into .NET and have imported the reports into the .NET project. Check the version of the CrystalDecisions.CrystalReports.Engine in your Project References.


Posted By: skyinsdevel
Date Posted: 12 Nov 2007 at 8:53am

Sorry, have been sent on another errand.  In VS2005 About there is no mention of the Crystal Reports number. I got 9.2.3300 with runtime v.1.0.3705 and another that is 10.2.3600.0 with v.2.0.50727




Print Page | Close Window