A Microsoft Office (Excel, Word) forum. OfficeFrustration

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.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Setting Up & Running Reports
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Why "RecordCount" is always -1 ?



 
 
Thread Tools Display Modes
  #1  
Old January 31st, 2006, 01:57 PM posted to microsoft.public.access.reports
external usenet poster
 
Posts: n/a
Default 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  
Old January 31st, 2006, 01:58 PM posted to microsoft.public.access.reports
external usenet poster
 
Posts: n/a
Default 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  
Old January 31st, 2006, 02:47 PM posted to microsoft.public.access.reports
external usenet poster
 
Posts: n/a
Default 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  
Old January 31st, 2006, 03:04 PM posted to microsoft.public.access.reports
external usenet poster
 
Posts: n/a
Default 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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 09:00 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.