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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CR8.5 - Date Range in RecSelFormula doesn't return any records.

Status
Not open for further replies.

WaveyDavey

Programmer
Jan 24, 2003
10
GB
I have imported my Crystal Report into the RDC in VB6 and followed the guidelines for converting from OCX to RDC. Everything is fine except for date ranges. I am applying them thus:
Code:
Dim vReport as CrystalReport1
Dim a as String
a = "{Table.DateField} in Date(2002,1,1) to Date(2002,1,31)"
vReport.RecordSelectionFormula=a

When I run the report, I get no records although there are some on the database (SQL Server 2000).

If I change the code thus:

Code:
a = "{Table.DateField} = Date(2002,1,1) or {Table.DateField} = Date(2002,1,31)"

I get 2 records on my report, assuming 1 record per day in January.

I can only assume that the date range format is incorrect.

The CR web site does not help.

Any help greatly appreciated.

Dave.
 
What you have should work, so I would check for typos.
I would also cut and paste a working selection formula into your program and see if that makes a difference.

You could also try this instead:

a = "{Table.DateField} >= Date(2002,1,1) and
{Table.DateField} <= Date(2002,1,31) &quot; Ken Hamady, On-site Custom Crystal Reports Training & Consulting
Public classes and individual training.
Expert's Guide to Formulas / Guide to Crystal in VB
- tek@kenhamady.com
 
After many hours of hair-pulling, I discovered that I had to go back to the original .rpt version of the report and remove the code from the SQL query found in Database|Show SQL Query and also the Record Selection Formula Editor found in Report|Edit Selection Formula|Record option. I then had to save the .rpt file again. In my VB app, I removed the CrystalReport .Dsr file in question and then added it again, bringing in the new version of the .rpt file.

As this new version of the report had no &quot;pre-defined&quot; queries inserted, the only selection used on the database was the RecordSelectionFormula I originally wanted to use.

Perhaps other users should be aware of this problem.

[red]REMEMBER : Remove all SQL Queries and RecordSelectionFormula coding from any .rpt report before importing it into CR8.5 ![/red]
 
CORRECTION : Remove all SQL Queries and RecordSelectionFormula coding from any .rpt report before importing it into Visual Basic!
 
I am pretty sure that you can override the SF from VB. So I wouldn't think you would have to clear the SF from the report.

However, if you have manually edited the SQL, then passing a SF will not update the SQL. You should reset the SQL in the Show SQL window before you incorporate the report into your app. Ken Hamady, On-site Custom Crystal Reports Training & Consulting
Public classes and individual training.
Expert's Guide to Formulas / Guide to Crystal in VB
- tek@kenhamady.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top