If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Why "RecordCount" is always -1 ?
"John" wrote in message ...
Dear all, Why "RecordCount" is always -1 ? Try a MoveLast then a MoveFirst. Tom Lake |
#2
|
|||
|
|||
Why "RecordCount" is always -1 ?
Dear all,
Why "RecordCount" is always -1 ? Private Sub Command18_Click() Dim cnn3 As ADODB.Connection Dim cmd3 As ADODB.Command Dim rst3 As ADODB.Recordset Dim thisStore As String Set rst3 = New ADODB.Recordset rst3.CursorType = adOpenDynamic Set cmd3 = New ADODB.Command thisStore = "T001" With cmd3 .ActiveConnection = CurrentProject.Connection .CommandText = "SELECT staff_code, store_code FROM on_duty WHERE Cstr(tx_date)='1/8/2006'" .CommandType = adCmdText End With Set rst3 = cmd3.Execute MsgBox rst3.RecordCount End Sub I don't know why the message box always return -1 even I have already tried : adOpenDynamic, adOpenKeyset. |
#3
|
|||
|
|||
Why "RecordCount" is always -1 ?
No, I got another error : "Rowset does not support fetching backward."
"Tom Lake" wrote in message ... "John" wrote in message ... Dear all, Why "RecordCount" is always -1 ? Try a MoveLast then a MoveFirst. Tom Lake |
#4
|
|||
|
|||
Why "RecordCount" is always -1 ?
I couldn't say why it is -1, but you could probably do something like this
to display the record count: msgbox Me.RecordsetClone.RecordCount "John" wrote in message ... Dear all, Why "RecordCount" is always -1 ? Private Sub Command18_Click() Dim cnn3 As ADODB.Connection Dim cmd3 As ADODB.Command Dim rst3 As ADODB.Recordset Dim thisStore As String Set rst3 = New ADODB.Recordset rst3.CursorType = adOpenDynamic Set cmd3 = New ADODB.Command thisStore = "T001" With cmd3 .ActiveConnection = CurrentProject.Connection .CommandText = "SELECT staff_code, store_code FROM on_duty WHERE Cstr(tx_date)='1/8/2006'" .CommandType = adCmdText End With Set rst3 = cmd3.Execute MsgBox rst3.RecordCount End Sub I don't know why the message box always return -1 even I have already tried : adOpenDynamic, adOpenKeyset. |
Thread Tools | |
Display Modes | |
|
|