Results 1 to 3 of 3

Thread: Date-selection with Crystal Reports in VB

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Sep 2002
    Posts
    26

    Date-selection with Crystal Reports in VB

    I have a date in my database. I select a date on my form in VB and then I have to compare this date with the data on the crystal report.

    sSelection = "{Planning.Medewerkernr} = " & CmboMedewerker.BoundText & " {Planning.datum} > " & Format(DPBegin, "dd-mm-yyyy")

    WeekReport2.SelectionFormula = sSelection
    WeekReport2.PrintReport


    It just does nothing. But when I put it like this it worked:

    sSelection = "{Planning.Medewerkernr} = " & CmboMedewerker.BoundText

    WeekReport2.SelectionFormula = sSelection
    WeekReport2.PrintReport


    The report was shown and the selection worked. How do I work with the date as a selection with crystal reports and VB?

  2. #2
    Hyperactive Member
    Join Date
    Mar 2002
    Location
    India
    Posts
    342

    chk if this wrks..

    sSelection = "{Planning.Medewerkernr} = " & CmboMedewerker.BoundText & " and {Planning.datum} > " & Format(DPBegin, "dd-mm-yyyy")
    ksm

  3. #3
    Addicted Member
    Join Date
    Apr 2002
    Location
    INDIA
    Posts
    169

    Hope this is what u want

    Hope this is what you were looking for!!! Let me know.

    private sub command1_click()
    Dim dat1, dat2 As Date
    dat1 = CDate(DTP1.Value)
    dat2 = CDate(DTP2.Value)
    If dat1 > dat2 Then
    msg = "Date in first text box should be" & vbCr
    msg = msg & "less than second text box"
    MsgBox msg, vbInformation
    Exit Sub
    End If
    craccreport.ReportFileName = App.Path & "\accountreport.rpt"
    yy1 = Year(DTP1.Value)
    mm1 = Month(DTP1.Value)
    dd1 = Day(DTP1.Value)
    yy2 = Year(DTP2.Value)
    MM2 = Month(DTP2.Value)
    dd2 = Day(DTP2.Value)
    p = "{Account.date} >= date(" & yy1 & "," & mm1 & "," & dd1 & ")and {Account.date} <= date(" & yy2 & "," & MM2 & "," & dd2 & ")"
    craccreport.SelectionFormula = p
    craccreport.Action = 1
    end sub

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