D
Deleted member 73419
Guest
I have the following code which performs a select query on the local database:
The trouble is that there are no records in the table which match the WHERE criteria but the RecordCount always returns 1 for some reason.
Strange thing is that if I run the SQL code in Query Designer, it doesn't return any records which is what you would expect the RecordCount to reflect in the VBA code...
Anyone have any ideas? Thanks
Code:
Sub Number()
Dim rs As DAO.Recordset
Dim db As DAO.Database
Dim SQL_SELECT As String
Set db = CurrentDb
SQL_SELECT = "SELECT Max(tblP.PN) AS PN FROM tblP WHERE (((tblP.PN) Like '1ABC*'));"
Set rs = db.OpenRecordset(SQL_SELECT)
If rs.EOF Then
Debug.Print "0"
Else
rs.MoveFirst
rs.MoveLast
Debug.Print rs.RecordCount
End If
End Sub
The trouble is that there are no records in the table which match the WHERE criteria but the RecordCount always returns 1 for some reason.
Strange thing is that if I run the SQL code in Query Designer, it doesn't return any records which is what you would expect the RecordCount to reflect in the VBA code...
Anyone have any ideas? Thanks