Try This
VB Code:
private sub command1_click()
Dim dat1, dat2 As Date
dim p As String
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
Don't forget to Include an Instance of Crystal report From Components, and Rename as 'craccreport'