Click here to Skip to main content
15,894,740 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
I get the error saying "This date time literal was not understood" with this formula:

VB
Private Sub btnOPrint_Click(sender As Object, e As EventArgs) Handles btnOPrint.Click
        If MsgBox("Print Offertory Record?", MsgBoxStyle.OkCancel, "Print Record") = MsgBoxResult.Ok Then
            Dim report As New ReportDocument
            report.Load("C:\Users\Paolo\Documents\Visual Studio 2015\Projects\NewMonitoringSystem\NewMonitoringSystem\OffertoryReport.rpt")
            docprint.CrystalReportViewer1.ReportSource = report
            docprint.CrystalReportViewer1.SelectionFormula = "{tblOffertory.Date}=""" & dtpOffertory.Text & """AND {tblOffertory.Weekly}=#" & txtOffertory.Text & "#"
            docprint.CrystalReportViewer1.Refresh()
            docprint.Show()
        End If
    End Sub


But if I remove the LINE
VB
AND {tblOffertory.Weekly}=#" & txtOffertory.Text & "#"
and use just this LINE which is what i'm supposed to use:
VB
docprint.CrystalReportViewer1.SelectionFormula = "{tblOffertory.Date}=""" & dtpOffertory.Text & """"


It show the report form but has no data in it, just the columns. Can anyone help me with the formula where I only use the Date. Thanks

What I have tried:

I tried the codes mentioned above but to no avail.
Posted
Updated 29-Sep-16 17:05pm

Try-
totext({tblOffertory.Date})

Hope, it helps :)
Please let me know if it doesn't help or if I am missing something here.
 
Share this answer
 
v2
Comments
Paolo Tansengco 29-Sep-16 22:50pm    
docprint.CrystalReportViewer1.SelectionFormula = "ToText({tblOffertory.Date})=""" & dtpOffertory.Text & """"


Still shows no data. just columns.
Paolo Tansengco 29-Sep-16 22:56pm    
And when I add the line
{tblOffertory.Weekly}
. An error shows up again saying This date time literal was not understood
Paolo Tansengco 29-Sep-16 23:06pm    
I got it work. Thanks for the idea.
Suvendu Shekhar Giri 30-Sep-16 1:55am    
Great to know that :)
VB
docprint.CrystalReportViewer1.SelectionFormula = "ToText(CDate({tblOffertory.Date}))= ToText(CDate(""" & dtpOffertory.Text & """))"


This code worked. Thanks for the idea @Suvendu
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900