G
GZ
Dim cnn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim strSQL As String
Set cnn = CurrentProject.Connection
Set rs = New ADODB.Recordset
strSQL = "Select * from Students where LName like '*Tom*' Or FName like
'*Tom*'"
rs.ActiveConnection = cnn
rs.ActiveConnection.CursorLocation = adUseClient
rs.Open strSQL, , adOpenDynamic, adLockOptimistic
msgbox rs.RecordCount
Hi, if I set
strSQL = "Select * from students"
Then the RecordCount returns correct number. But if run the above code, the
RecordCount returns 0.
But there are do many Toms in the Students table, and the same code strSQL =
"Select * from Students where LName like '*Tom*' Or FName like '*Tom*'"
returns correct number on that form (which uses Me.RecordSource = strSQL).
However, this form is created from blank, so there is no Me.RecordSource
set.
What 's wrong?
Dim rs As ADODB.Recordset
Dim strSQL As String
Set cnn = CurrentProject.Connection
Set rs = New ADODB.Recordset
strSQL = "Select * from Students where LName like '*Tom*' Or FName like
'*Tom*'"
rs.ActiveConnection = cnn
rs.ActiveConnection.CursorLocation = adUseClient
rs.Open strSQL, , adOpenDynamic, adLockOptimistic
msgbox rs.RecordCount
Hi, if I set
strSQL = "Select * from students"
Then the RecordCount returns correct number. But if run the above code, the
RecordCount returns 0.
But there are do many Toms in the Students table, and the same code strSQL =
"Select * from Students where LName like '*Tom*' Or FName like '*Tom*'"
returns correct number on that form (which uses Me.RecordSource = strSQL).
However, this form is created from blank, so there is no Me.RecordSource
set.
What 's wrong?