0

hi! i have an application which will filter my access db for expiring dates and it will print using crystal report. the expiry date format on my database is as short text. so far this is my code. it prints the records but only when i choose the exact dates.i hope you could help me.

Private Sub btnPrint_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPrint.Click
        With frmReport
            If chkPrintAll.Checked = False Then
                Call OpenConnection()
                Call Initialized()
                With OleDa
                    .SelectCommand = New OleDbCommand()
                    .SelectCommand.CommandText = "SELECT * FROM [tblInfo] WHERE [ExpiryDate] BETWEEN '" & dtpPrintFrom.Text & "' AND '" & dtpPrintTo.Text & "'"
                End With
                .strReport = "Filter"

                .strWhere = "{tblInfo.ExpiryDate} IN '" & dtpPrintFrom.Text & "' TO '" & dtpPrintTo.Text & "'"
            Else
                .strReport = "Print All"
            End If
            frmReport.ShowDialog()
        End With
    End Sub
2
Contributors
1
Reply
9
Views
2 Years
Discussion Span
Last Post by David_50
0

Why the .strWhere, when 'where ... between' already in SQL? Is it just a title, since it is not a legal SQL 'IN'? Id the input date in a form native to this SQL engine? Try "YYYY-mm-dd HH:MM:SS.ssssss" (ISO date).

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.