Solved

recordcount not working......

Posted on 2002-05-24
3
137 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 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 50 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to debug this code 7 56
Access query that references subform 5 43
Convert VB6 MSXML2.ServerXMLHTTP process to C# 2 40
VBA Shell can't Find Word document 11 74
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.
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

932 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now