Sync between recordset and access table

ppp

New member
Local time
Today, 04:38
Joined
Oct 15, 2014
Messages
2
Hello everybody,
I have a normal Access table. The first column is ID and is the primary key. The second column is a text. The table consists of two records and is sorted in ascending order. First comes the data set with the ID 1.

Sub test()
Set rs_access = CurrentDb.OpenRecordset("tab1")
rs_access.MoveFirst
MsgBox (rs_access.Fields("id").Value)
End Sub

The message box shows 1. So everything is fine. Now I sort the table descending. But I get the same message. Why? Appearently the recordset doesn't know that the table was modified. The recordset should register that the table is modified. Can someone give me a hint?
 
The sort of the table is -as wierd as it sounds- NOT on the table.

Everytime you open a table view it is essentially a Select query... every query on its on is per default RANDOM, i.e. has no guaranteed order... 99% of the time it is 99% ordered in the way it is entered... HOWEVER do not mistake ... this is no guarantee!!!

The only guarantee you have is if you do an explicit order of your query or recordset... If you dont have an ORDER BY statement (or rs.orderby, i believe it is) then you DO NOT have an order.

Best course of action...
Set rs_access = CurrentDb.OpenRecordset("Select * from tab1 order by ID desc")
 

Users who are viewing this thread

Back
Top Bottom