Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

record count

Posted on 2000-04-29
8
Medium Priority
?
187 Views
Last Modified: 2010-05-02
There are 4 records in the database but the record count in the msgbox only show 1.  I know I am missing something simple but untill I can get to a good book I am stabbing in the dark till then.  And the online help is not helping much.  So here is my play code if you could give me some guidance please.

Option Explicit
'declare database variables
Public db As Database
Public rs As Recordset
Private Sub Cancel_Click()

    'quits login and closes program
    Unload LogInForm
   
End Sub
Private Sub Form_Load()
 
    'open database
    Set db = DBEngine.Workspaces(0).OpenDatabase(App.Path & "\tenneco.mdb")
    Set rs = db.OpenRecordset("select pcid from workcells")
       
    'centers login in center of screen
    Me.Top = (Screen.Height - Me.Height) / 2
    Me.Left = (Screen.Width - Me.Width) / 2
       
End Sub
Private Sub LogIn_Click()

    MsgBox rs.RecordCount
       
End Sub
0
Comment
Question by:csindorf
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 6

Accepted Solution

by:
Marine earned 60 total points
ID: 2763039
Set db = DBEngine.Workspaces(0).OpenDatabase(App.Path & "\tenneco.mdb")
    Set rs = db.OpenRecordset("select pcid from workcells")

this will create a read only recordset . Any way you should do this.
Set db = DBEngine.Workspaces(0).OpenDatabase(App.Path & "\tenneco.mdb")
    Set rs = db.OpenRecordset("select pcid from workcells",dbOpenDynaset)
then you can
rs.Movelast
rs.RecordCount
msgbox rs.RecordCount
0
 
LVL 6

Expert Comment

by:Marine
ID: 2763043
if you want to have recordset readonly then you can do the same but just replace dbOpenDynaset with dbOpenSnapshot.
GoodLuck.
0
 
LVL 1

Expert Comment

by:SpyMaster
ID: 2763958
This is defiantly a bug because I have experienced the same problems in the past.  You need to refresh the recordset.  Do as Marine suggested but include this so that your program does not generate a runtime error if there are 0 records.

If rs.RecordCount > 0 Then rs.Movelast
MsgBox rs.RecordCount
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 6

Expert Comment

by:Marine
ID: 2763965
spyMaster then you should take away your Answer as Proposed one. It wouldn't be fare to place an answer to which i had given  a correct answer as well.
0
 
LVL 1

Expert Comment

by:SpyMaster
ID: 2764004
Oh sorry Marine, new to this... Registered with the service today.
0
 
LVL 6

Expert Comment

by:Marine
ID: 2764010
oh, Welcome to EE. It's a great site for Tech Stuff. Enjoy.
0
 
LVL 1

Expert Comment

by:tirupur_selva
ID: 2764134
It would be even better if rs.movefirst is called after rs.movelast-this would bring back to the first position, all other things stated above by other experts would work fine.
0
 
LVL 2

Expert Comment

by:Glen Richmond
ID: 2764935
yes they are rite you need the DB cursor on the last record in the recordset to return the correct record count and use rs.movefirst or rs.moveprevious to return to origonal cursor position.
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
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.
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

636 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