PerkinsSlave
New Member
- Joined
- Feb 1, 2004
- Messages
- 26
Good morning,
I am attempting to open a recordset in VBA. I have used the same procedure countless times in the past, but it doesn't seem to be working today, and it's driving me nuts! Here's the code:
Public Sub Test1()
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim sSQL As String
Dim iCount As Integer
sSQL = "SELECT * FROM tblCSAInfo"
Set db = CurrentDb()
Set rs = db.OpenRecordset(sSQL)
iCount = rs.RecordCount
MsgBox "There are " & iCount & " records."
rs.Close
Set rs = Nothing
Set db = Nothing
End Sub
The table in question, tblCSAInfo, has 368 records. The code listed above returns a value of 1 to iCount. Now, if I replace the sSQL statement with just "tblCSAInfo" I receive an accurate count.
I know I'm missing something obvious, I just can't seem to figure out what it is. Adding to the frustration is that this method works in other modules.
Thanks,
Paul
I am attempting to open a recordset in VBA. I have used the same procedure countless times in the past, but it doesn't seem to be working today, and it's driving me nuts! Here's the code:
Public Sub Test1()
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim sSQL As String
Dim iCount As Integer
sSQL = "SELECT * FROM tblCSAInfo"
Set db = CurrentDb()
Set rs = db.OpenRecordset(sSQL)
iCount = rs.RecordCount
MsgBox "There are " & iCount & " records."
rs.Close
Set rs = Nothing
Set db = Nothing
End Sub
The table in question, tblCSAInfo, has 368 records. The code listed above returns a value of 1 to iCount. Now, if I replace the sSQL statement with just "tblCSAInfo" I receive an accurate count.
I know I'm missing something obvious, I just can't seem to figure out what it is. Adding to the frustration is that this method works in other modules.
Thanks,
Paul