Private Sub cmdPrint_Click()

Dim cnview As New ADODB.connection
Dim rsview As New ADODB.Recordset

    Call connection(cnview, App.Path & "\Seeyou.mdb", "endromida")
    'Call connection(cnview, "\\SEEYOU-PC\shared\Seeyou.mdb", "endromida")
    Call Recordset(rsview, cnview, "SELECT * FROM [order] where Edate = #" & txtEdate.Text & "#")

    If rsview.RecordCount = 0 Then
        MsgBox "No Record Found On Query.", vbCritical, "Seeyou"

    Else

        Set DayOrds.DataSource = rsview
        DayOrds.Orientation = rptOrientLandscape
        DayOrds.Show
    End If

End Sub

Error is : No Records Found
Even there are records in database, i am trying to filter data on base of Date
Is this Query is right?

Dani AI

Generated

Both and are pointing at the right areas: using a reserved word for a table name is risky (brackets make it valid, but renaming improves maintainability), and the EDate field type/format is the most common root cause. Typical reasons a query returns zero rows even though data exists: the SQL date literal format doesn't match the stored values, the EDate column contains a time component so an equality test fails, or the Recordset/cursor settings make RecordCount unreliable.

A practical checklist and fixes:

  • Validate the input value is a date (IsDate) and convert it to a Date type before building SQL.
  • Create an unambiguous Access date literal (Access SQL expects #mm/dd/yyyy# format) or, better, use a day-range to ignore time parts.
  • Prefer checking rs.EOF (and rs.BOF) instead of relying solely on RecordCount, or open the recordset with a client-side/static cursor so RecordCount is supported.

Example pattern (VB6/ADO) that addresses format and time-component issues:

If Not IsDate(txtEdate.Text) Then Exit Sub
Dim d As Date: d = CDate(txtEdate.Text)
Dim sql As String
sql = "SELECT * FROM [order] WHERE EDate >= #" & Format(d,"mm\/dd\/yyyy") & "# AND EDate < #" & Format(d + 1,"mm\/dd\/yyyy") & "#"

cnview.CursorLocation = adUseClient
rsview.Open sql, cnview, adOpenStatic, adLockReadOnly

If rsview.EOF Then
    MsgBox "No Record Found", vbCritical, "Seeyou"
Else
    ' bind/display results
End If

Additional tips: Debug.Print the final SQL and paste it into Access to verify results; confirm EDate is a Date/Time column (not text); ensure the helper routines that open the connection/recordset set cursor location/cursor type; consider using a Command with parameters to avoid literal-format issues. These steps identify whether the problem is format, time component, or cursor behavior.

Recommended Answers

All 2 Replies

  1. Rename your column name 'order' because ORDER is a reserve words/keyword in sql.
  2. Check your date format (Edate = #" & txtEdate.Text & "#")

: order is not here a column name . It is a table name. nothing happens because it is in square bracket.

check the field type of EDate and also if it is date type format the text properly.

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.