I've had this problem on several occasions, but I always assumed the error was something else. The current episode is the simplest, so I don't see another error to blame.
My goal is to parse several .txt reports. My table has two fields, ID, an autonumber, and strRaw, an 80-character string. The only index on the table is the PrimaryKey, ID. The table is populated by importing atext file into strRaw. The lowest ID is for the first line of the report. No problems so far.
My parsing routine uses a very simple instruction:
Set rstRaw=CurrentDB.OpenRecordset("tblRaw")
to open the table. After stepping through this instruction, I enter
Debug.Print rstRaw!ID
in the immediate window. The ID is several hundred records into the 4000-record table. I repeat the process; the results are the same. I delete the data and import another report. The ID just after opening is again somewhere in the middle of the file. Repeating the process yields the same record on the same data, but different records on different data.
Where have I gone wrong? I didn't want to open the table dbOpenForwardOnly; the reports are often so long that I don't want all the data in memory, even though I make just one pass through it. (I guess I could if that would solve the problem) Do I have to open any sequence-critical table as a dynaset from a query with an Order By clause?
Set rstRaw=CurrentDB.OpenRecordset("SELECT * FROM tblRaw ORDER BY PrimaryKey")
Thanks for your help!
My goal is to parse several .txt reports. My table has two fields, ID, an autonumber, and strRaw, an 80-character string. The only index on the table is the PrimaryKey, ID. The table is populated by importing atext file into strRaw. The lowest ID is for the first line of the report. No problems so far.
My parsing routine uses a very simple instruction:
Set rstRaw=CurrentDB.OpenRecordset("tblRaw")
to open the table. After stepping through this instruction, I enter
Debug.Print rstRaw!ID
in the immediate window. The ID is several hundred records into the 4000-record table. I repeat the process; the results are the same. I delete the data and import another report. The ID just after opening is again somewhere in the middle of the file. Repeating the process yields the same record on the same data, but different records on different data.
Where have I gone wrong? I didn't want to open the table dbOpenForwardOnly; the reports are often so long that I don't want all the data in memory, even though I make just one pass through it. (I guess I could if that would solve the problem) Do I have to open any sequence-critical table as a dynaset from a query with an Order By clause?
Set rstRaw=CurrentDB.OpenRecordset("SELECT * FROM tblRaw ORDER BY PrimaryKey")
Thanks for your help!