I'm working with VBA in Access 2010 and I have an odd problem. I'm trying to pull records from a table, but my SELECT query is only returning a single record.
There are three records in the table, but the recordset is only getting the first one.
Here's my code.
Dim cc As String
Dim DB As Database
Dim rst As recordset
Dim sqlstr As String
Dim e As Integer
cc = CmbClass.Text
If cc = "" Then Exit Sub
sqlstr = "SELECT * FROM Students" 'WHERE CCode ='" & cc & "'"
Set DB = CurrentDb
Set rst = DB.OpenRecordset(sqlstr)
'Debug.Print rst.Fields(0)
e = rst.RecordCount
Debug.Print e
If e = 0 Then Exit Sub
The value of e is continually 1, not 3. As you can see I originally had a more complex SQL string, but I've cut it down to the most basic while trying to troubleshoot, yet the problem persists. Does anyone know why this is happening?
Thanks,
Tam.