The data in a table is not stored in any particular order. Sorting it by a certain field will change how it is displayed, but won't change the order the records are accessed in a VBA recordset. For that, we need to set an index.
Open the underlying table in design view and add a new index on the field (or fields) that you want the order based on. Then set the index property of the recordset before you call MoveFirst. Something like this:
- Set raw = mydb.OpenRecordset("2_Base_Demands_by_Week")
-
raw.Index = "myIndex"
-
raw.MoveFirst
If needed, you can also create the index programatically - lookup the TableDef.CreateIndex method in help. I don't use it much, so the code example will probably be easier to follow than my explanation.