View Full Version : Why is my RecordSet not starting from record 1
Hello all;
There may be a simple explanation to this, and hoping someone can help me.
I can't figure out why my Recordset start from record # 301 instead of # 1. Here's a screen shot:
12214
Table has 12,000 records and the first record has an ID of 1. So why is it start from the record 301? What am I doing wrong?
I thank you for your time.
BJ
That's the order that the records were added.
If the field is indexed it will have a sort order but that sort is only used when opening tables and queries, etc.
To apply the index to a recordset get it from the tabledef. e.g.
Set td = db.TableDefs(tbl)
Dim idx As DAO.Index
For Each idx In td.Indexes
If idx.Primary Then
rs.Index = idx.Name
Exit For
End If
Next
Or just specify sort order when you create the rs
set rs = db.openrecordset("select * from strtable2 order by id asc")
Hi Jonh, thank you so much for your reply. I think I will go with the query method for my purpose now. But thanks for clarifying why it wasn't doing what I expected.
Or just specify sort order when you create the rs
set rs = db.openrecordset("select * from strtable2 order by id asc")
BJ :hi:
ranman256
09-02-2014, 09:10 AM
you can skip the movefirst, movelast, statments.
it always starts at the 1st.
ranman256
09-10-2014, 05:22 AM
.remove this ;pls.
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.