Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

recordcount not working......

Posted on 2002-05-24
3
Medium Priority
?
157 Views
Last Modified: 2010-05-02
i am using a stored procedure to "fill" a recordset but the recordset.recordcount = 0 doesnt seems to work at all!
anyone can point me into the right direction?

sqlstr = "up_Top_ABCD '" & period8 & "' "

Set rsInvDetailStatus = New ADODB.Recordset

With rsInvDetailStatus
  .CursorLocation = adUseServer
  .Open sql66, frmMainMenu.db, adOpenKeyset, adLockBatchOptimistic, adCmdText
End With

If rsInvDetailStatus.RecordCount = 0 Then
  errmsg = MsgBox("No matching records found!", vbCritical, "No records found")
  Set rsInvDetailStatus.ActiveConnection = Nothing

else

 msgbox "have records"

end if
0
Comment
Question by:spiral
3 Comments
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 150 total points
ID: 7031593
instead of
If rsInvDetailStatus.RecordCount = 0 Then
use
If rsInvDetailStatus.BOF and rsInvDetailStatus.EOF Then

Explanation:
the value of Recordcount is most surely -1, as the cursorlocation is on the server (if you can change to client, this can solve, but not in all the cases). The only expression that can be used for sure is the .eof and .bof

CHeers
0
 
LVL 1

Expert Comment

by:zzconsumer
ID: 7031687
Before opening the Recordset, use:

rsInvDetailStatus.CursorLocation = adUseClient

This will enable you to use .RecordCount
0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 7032196
I am sure if you were to maintain your open questions, you would find experts more receptive.  For the record:

Questions Asked 19
Last 10 Grades Given A A B A A B A B B B  
Question Grading Record 11 Answers Graded / 11 Answers Received

Anthony
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question