Computer Learning Zone CLZ Access Excel Word Windows

Never let the competition know what you're thinking.

-85th Rule of Acquisition
 
Home   Courses   TechHelp   Forums   Help   Contact   Merch   Join   Order   Logon  
 
Back to Microsoft Access 320    Comments List
Upload Images   @Reply   Bookmark    Link   Email   Next Unseen 
Recordset going to last record
Zachary Marsett 
    
13 years ago
Richard,
For some reason my recordset is going to the last record I have saved in my table. As I change the last record in the table, sure enough that's what comes up in the FirstName box. I can't figure out how I'm messing up the syntax.  Here's the code I have saved:
Private Sub Command0_Click()
Dim db As dao.Database
Dim rs As Recordset

Set db = CurrentDb
Set rs = db.OpenRecordset("ChildT")

rs.MoveFirst
While Not rs.EOF
    FirstName = rs!FirstName
    rs.MoveNext
Wend

rs.Close
db.Close

Set db = Nothing
Set rs = Nothing

Is there something wrong right in front of me that I'm not noticing?


Reply from Richard Rost:

If you don't specify a sort order in your recordset, you cannot be guaranteed that the records will be in any particular order. If you want to FORCE them to sort in order, you need to say something like:

Set rs = db.OpenRecordset("SELECT * FROM ChildT ORDER BY ChildID")

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

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/6/2026 6:10:40 PM. PLT: 1s