Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with using recordsortfields with CrViewer

Status
Not open for further replies.

MadCatmk2

Programmer
Oct 3, 2003
145
GB
Hi all

I currently have code which out puts the correct data onto a Crystal report viewed with the CRViewer control in vb6. I have one problem however. Once i have added the group in the second if statement i would like to sort the data based on the date of birth field. For some reason the code isn't working. The code is as follows

Code:
Private Sub Cadob1a()
Dim Report As New CRCaDob1a
CRViewer91.ReportSource = Report
SetReportLocation Report
Report.DiscardSavedData
Report.RecordSelectionFormula = RecordSelectionFormulaString
Report.GroupSelectionFormula = GroupSelectionFormulaString
Report.Text1.SetText ReportHeading
If ReportType = "'BySurname'" Or ReportType = "'CNT'" Or ReportType = "'PNT'" Or ReportType = "'Selected'" Then

msgbox "Surname Report"
    
End If
If ReportType = "'ByAge'" Or ReportType = "'Under5'" Or ReportType = "'5to74'" Or ReportType = "'Over75'" Then
    
    'This adds a group based on the current age formula.
    Report.AddGroup 0, Report.FormulaFields.Item(2), crGCAnyValue, crAscendingOrder
    
    Report.RecordSortFields.Add Report.Database.Tables.Item(1).Fields.Item(4), crAscendingOrder
    
End If
CRViewer91.ViewReport
Screen.MousePointer = vbDefault
Exit Sub
End Sub

I would appreciate any help in identifying whats wrong with the code i have. I know that the database table and field points tward the date of birth field and that this field is included in the report.

All help is much appreciated.

Thanks in advance
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top