0
votes

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    reportdoc1.Load(Server.MapPath("~\RepVoucherchq.rpt"))
    CrystalReportViewer1.ReportSource = reportdoc1
    ConnectionInfo()

    Dim user_brno As String = CType(Session("userBrn"), String)
    Dim date_from As String = CType(Session("date_from"), String)
    Dim date_to As String = CType(Session("date_to"), String)

    reportdoc1.RecordSelectionFormula = "{VEWVoucherchq.vocdate} between '" + date_from + "' and '" + date_to + "'  and {VEWVoucherchq.chqbrNo} = " + user_brno
    CrystalReportViewer1.RefreshReport()

End Sub
1
More details? It's too plain question.Federico Navarrete

1 Answers

0
votes

I don't have Visual Studio on this computer to test this completely, but I think your syntax is off in your Record Selection Formula.

Try this instead:

reportdoc1.RecordSelectionFormula = "{VEWVoucherchq.vocdate} in '" + date_from + "' to '" + date_to + "' and {VEWVoucherchq.chqbrNo} = " + user_brno

The between/and syntax you used isn't supported in Crystal Reports for evaluating a date the way you want. The supported syntax is {eval_date} IN {start_Date} to {end_Date}.

You may also run into an issue with your date_from and date_to fields being string data types instead of the Date or DateTime datatype. If that is an issue, you will want to pass the values through a function to convert them to dates properly.

Something like this should suffice:

reportdoc1.RecordSelectionFormula = "{VEWVoucherchq.vocdate} in Date('" + date_from + "') to Date('" + date_to + "') and {VEWVoucherchq.chqbrNo} = " + user_brno

If you need DateTime instead of Date data types, replace the Date() functions with DateTime() functions.