Results 1 to 7 of 7

Thread: [RESOLVED] Crystal Report Selection Formula (Urgent)

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Apr 2002
    Posts
    94

    Resolved [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:
    1. With crStudList
    2.         .Connect = strConn
    3.         .ReportFileName = App.Path & "\reports\StudentList.rpt"
    4.         .ReportTitle = "Student List"
    5.         .WindowTitle = "Student List"
    6.         .SelectionFormula = "{tblStudent.RegistrationDate}>=#" & dtpFrom.Value & "# and {tblStudent.RegistrationDate}<=#" & dtpTo.Value & "#"
    7.         .WindowState = crptMaximized
    8.         .Destination = crptToWindow
    9.         .Action = 1
    10.     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
    Last edited by damini_dd; Feb 15th, 2006 at 10:03 AM. Reason: to add vbcode tag

  2. #2
    Frenzied Member the182guy's Avatar
    Join Date
    Nov 2005
    Location
    Cheshire, UK
    Posts
    1,473

    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
    Chris

  3. #3
    A SQL Server fool GaryMazzone's Avatar
    Join Date
    Aug 2005
    Location
    Dover,NH
    Posts
    7,493

    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:
    1. strW = "{ExposureRecords.StartDate} = DateValue ('" & cboStartDate.Text & "')"

    For you possibley:
    VB Code:
    1. .SelectionFormula = "{tblStudent.RegistrationDate}>= DateValue (" & dtpFrom.Value & ") and {tblStudent.RegistrationDate}<= DateValue(" & dtpTo.Value & ")"
    Sometimes the Programmer
    Sometimes the DBA

    Mazz1

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Apr 2002
    Posts
    94

    Re: Crystal Report Selection Formula (Urgent)

    Thanks.

    I am enclosing my form

    And GaryMazzone i tried ur code but its giving no data
    Attached Files Attached Files
    Last edited by damini_dd; Feb 15th, 2006 at 11:21 AM.

  5. #5
    A SQL Server fool GaryMazzone's Avatar
    Join Date
    Aug 2005
    Location
    Dover,NH
    Posts
    7,493

    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)
    Sometimes the Programmer
    Sometimes the DBA

    Mazz1

  6. #6

    Thread Starter
    Lively Member
    Join Date
    Apr 2002
    Posts
    94

    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

  7. #7

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width