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

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).

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.