Print Page | Close Window

need help w/date range selection error

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=8039
Printed Date: 04 May 2024 at 1:04am


Topic: need help w/date range selection error
Posted By: DoubleNickel
Subject: need help w/date range selection error
Date Posted: 15 Oct 2009 at 12:17pm

First post:

I followed the example from page 296 (.net 2005/2008) listing 15-1,  it generated an error stating that the formula was not a string.

So I put single quotes into the formula, then got a different error. This time stating that the result must be a boolean. 
 
I am just trying to select records where deposit date falls within a range of dates.  When I remove the selection formula the report displays in the viewer or prints via printoprinter... 
 
I entered the code into the selection formula imbeded in the report that worked just fine. Next I copied the selection formula from the editor.  The resulting error message when I run the code contains the exact same value as the formula.
 
 
 
 
db as env:
SQL Server 2008, VS 2008 the table is flat for this report nothing complex.
 
Data structure:
Check No, Check Date, Deposit Date, First Name, Last Name, Check Amount
 
Code follows:
        Dim sFrom As String
        Dim sTo As String
        With DateTimePicker1.Value
            sFrom = .Year.ToString & "," & .Month.ToString.PadLeft(2, Chr(48)) & "," & .Day.ToString.PadLeft(2, Chr(48))
        End With
        With DateTimePicker2.Value
            sTo = .Year.ToString & "," & .Month.ToString.PadLeft(2, Chr(48)) & "," & .Day.ToString.PadLeft(2, Chr(48))
        End With
        Dim sb As New StringBuilder
        sb.Append("'{Payment_History.Deposit_Date} in (Date(")
        sb.Append(sFrom & ") to Date(")
        sb.Append(sTo & "))'")
        Dim myReport As New CrystalReport2
        myReport.DataDefinition.RecordSelectionFormula = sb.ToString
        CrystalReportViewer1.ReportSource = myReport
 
 
 


-------------
bought for a price



Print Page | Close Window