Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   TechHelp   Forums   Help   Contact   Merch   Join   Order   Logon  
 
Back to Access Forum    Comments List
Upload Images   @Reply   Bookmark    Link   Email   Next Unseen 
Recordset Strangeness
simon b 

11 years ago
Table Name NumT Fields ID Autonumber , NumValue Number Double

NumT - ID 1 NumValue = 7608
NumT - ID 241 NumValue = 4681
NumT Total Records = 30000
Set Rs = Db.OpenRecordset("NumT")
    
    Rs.MoveLast
    MsgBox Rs.RecordCount
    Rs.MoveFirst
    
    While Not Rs.EOF
        MsgBox Rs!ID
        MsgBox Rs!NumValue
    
        Rs.MoveNext
    Wend

    Msgbox--OUTPUT--------
    Rs.Recordcount = 30000
    Rs!ID = 241
    Rs!NumValue = 4681

----------------------------------------------------

Set Rs = Db.OpenRecordset("NumT", dbOpenTable)

Msgbox--OUTPUT--------
Rs.Recordcount = 30000
Rs!ID = 241
Rs!NumValue = 4681

-----------------------------------------------------

Set Rs = Db.OpenRecordset("NumT", dbOpenSnapshot)

Msgbox--OUTPUT--------
Rs.Recordcount = 30000
Rs!ID = 241
Rs!NumValue = 4681

-------------------------------------------------------

Set Rs = Db.OpenRecordset("NumT", dbOpenForwardOnly)
MsgBox Rs.RecordCount
    
    While Not Rs.EOF
        MsgBox Rs!ID
        MsgBox Rs!NumValue
    
        Rs.MoveNext
    Wend

Msgbox--OUTPUT--------
Rs.Recordcount = 1
Rs!ID = 241
Rs!NumValue = 4681

---------------------------------------------------------

Set Rs = Db.OpenRecordset("NumT", dbOpenDynaset)

Msgbox--OUTPUT--------
Rs.Recordcount = 1
Rs!ID = 1
Rs!NumValue = 7602

---------------------------------------------------------

Set Rs = Db.OpenRecordset("SELECT * FROM NumT")

Msgbox--OUTPUT--------
Rs.Recordcount = 1
Rs!ID = 1
Rs!NumValue = 7602

----------------------------------------------------------

I have used the following code whilst playing around with different sorting methods and arrays and
noticed something a bit odd. The above shows my findings i was just checking that my recordset set
was working correctly and found that opening the recordset by any other methods other than DbOpenDynaset
or using an SQL statement caused the recordset to miss the first 240 entries in the table and start at ID
241.I am aware that the recordcount needs in some cases in order to give the correct result needs the
recordset to be on the last record but have not come accross the recordset missing any of the records in
the table.
Anybody any thoughts or ideas why this is happening?



Reply from Alex Hedley:

I usually check for BOF then move first

If Not (rs.BOF And rs.EOF) Then
rs.MoveFirst

This thread is now CLOSED. If you wish to comment, start a NEW discussion in Access Forum.
 

Next Unseen

 
New Feature: Comment Live View
 
 

The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.
 

Learn
 
Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Seminars
More...
Customers
 
Login
My Account
My Courses
Lost Password
Memberships
Student Databases
Change Email
Info
 
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Help
 
Customer Support
Web Site Tour
FAQs
TechHelp
Consulting Services
About
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Free Lessons
Mailing List
PCResale.NET
Order
 
Video Tutorials
Handbooks
Memberships
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Contact
 
Contact Info
Support Policy
Mailing Address
Phone Number
Fax Number
Course Survey
Email Richard
[email protected]
Blog RSS Feed    YouTube Channel

LinkedIn
Copyright 2026 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 5/15/2026 5:26:30 AM. PLT: 0s