[RESOLVED] Crystal Report Selection Formula (Urgent)
Hi Friends,
I am using crystal report to get the list of students registered between two dates. I am using vb6 as front end I've written following code to display report:
VB Code:
With crStudList
.Connect = strConn
.ReportFileName = App.Path & "\reports\StudentList.rpt"
.ReportTitle = "Student List"
.WindowTitle = "Student List"
.SelectionFormula = "{tblStudent.RegistrationDate}>=#" & dtpFrom.Value & "# and {tblStudent.RegistrationDate}<=#" & dtpTo.Value & "#"
.WindowState = crptMaximized
.Destination = crptToWindow
.Action = 1
End With
Where DtpFrom and and dtpTo are DtpPicker control which are used to select start and end date value. I've set its format to customFormat and Custom format i've set is "dd/MM/yyyy"
Its not giving any errors but if i give 01/02/2006 as start date and 28/02/2006 as end date, it should display only students' who have register in between these two dates but it displays all who registered in 02/01/2006 or 20/01/2006 or 08/01/2006.
plz help.
thx a lot
Re: Crystal Report Selection Formula (Urgent)
Could you give us the rest of the code for the app? I cant see what the problem is from only seeing this with statement. We need to see the function (if possible) which parses the .SelectionFormula data.
Chris
Re: Crystal Report Selection Formula (Urgent)
When I pass a date into CR for use in a selection criteria I use the DateValue function in CR like this:
VB Code:
strW = "{ExposureRecords.StartDate} = DateValue ('" & cboStartDate.Text & "')"
For you possibley:
VB Code:
.SelectionFormula = "{tblStudent.RegistrationDate}>= DateValue (" & dtpFrom.Value & ") and {tblStudent.RegistrationDate}<= DateValue(" & dtpTo.Value & ")"
1 Attachment(s)
Re: Crystal Report Selection Formula (Urgent)
Thanks.
I am enclosing my form
And GaryMazzone i tried ur code but its giving no data
Re: Crystal Report Selection Formula (Urgent)
I can't get the form to load completely on my system but did you look at this:
This is the format for the DateSerail function in CR DateSerial (Year, Month,Day)
So like this if the date is today (2/15/2006) then DateSerial(2006,2,15)
Re: Crystal Report Selection Formula (Urgent)
Thanks GaryMazzone
Bt what u want to do change in my code? I just changed formula as per ur suggestion.
regards
damini
Re: Crystal Report Selection Formula (Urgent)