Click to See Complete Forum and Search --> : Selecting Date Range problem


pepsisc
May 1st, 2006, 07:53 AM
OS=Windows XP Pro; VB 6 Enterprise; Crystal Report X! - Developers Edition

DataBase = Access TableName = "TrackingTable" FieldName = "dbTrackPODate" Text - 10 (date is entered in format mm/dd/yyyy)
In the VB6 application, in the General.Bas, I have defined:

Public HoldStartDate As String
Public HoldEndDate As String

I then use InputBox's to have the user type in the range of dates (format:mm/dd/yyyy)

I am trying to use this selection formula to pass to the CR report:

craxreport.FormulaSyntax = crCrystalSyntaxFormula
craxreport.RecordSelectionFormula = "{TrackingTable.dbTrackPODate} between #" & HoldStartDate & "# and #" & HoldEndDate & "#"

I am getting the following error message: "The remaining text does not appear to be part of the formula".

Please, I am in need of getting this done today. If you can help, thank you,Sam

pepsisc
May 1st, 2006, 11:01 PM
Hey folks, I finally got it. Thanks to all for their help. Here is the code:

Set craxreport = craxapp.OpenReport(ReportPath & "\" & ReportName)
craxreport.FormulaSyntax = crCrystalSyntaxFormula
Dim ReverseSD As String
Dim ReverseED As String
Dim mm As String
Dim dd As String
Dim yyyy As String

ReverseSD = Right(HoldStartDate, 4) & "/" & Left(HoldStartDate, 2) & "/" & Mid(HoldStartDate, 4, 2)
ReverseED = Right(HoldEndDate, 4) & "/" & Left(HoldEndDate, 2) & "/" & Mid(HoldEndDate, 4, 2)
strFilter = "CDate ({TrackingTable.dbTrackPODate}) >= #" & ReverseSD & "# and CDate({TrackingTable.dbTrackPODate}) <= #" & ReverseED & "#"
craxreport.RecordSelectionFormula = strFilter