L
Lee
(Access 97)
I have a situation where, depending on how data is read, rows inserted into
a table are not available for select until several seconds after the inserts
are finished.
Has anybody seen something like this before? Any ideas why I would get a
delay between the time when data is inserted and when it can be selected?
More info below.
Thanks!
Lee
More Info
==============
Steps:
(1) Import data from text file into table (140 rows)
(2) Add about 100 more rows to the table using
recordset.AddNew ... recordset.Update
(I close the insert recordset when done.)
(3) Query the data
I need to add a 3-second delay between steps 2 and 3, otherwise the select
in step 3 sees only the data imported in step 1, but not any data inserted
in step 2.
For diagnostics I have added calls to DMax() and DLookup() between steps 2
and 3. Strangely, these calls see all the data even when the select
statement that follows them does not.
Notes:
* The table is a link to an Access table in a separate .MDB file.
* Table connection is: ";DATABASE=(path)\MRData.mdb"
* I am not using replicated databases.
* I am not doing any asynchronous processing (as far as I know!)
* I am not using transactions.
* I tried using transactions as a possible fix -- no help.
* Both the code MDB and the data MDB reside in same folder.
* Both .MDB's are on my local drive.
* I have re-installed Access 97 SR-2, and Jet 3.5 SR 3
* I have repaired and compacted (again and again ...)
Code summary
============================================================
============================================================
''
'' Import 140 rows from text file for User "A".
'' Largest value of ItemNum field is 6
''
DoCmd.TransferText acImportDelim, "ImportV1", "tblData", _
strImportFile, HasFieldNames:=True
Set db = CurrentDB()
''
'' Insert an additional 100 rows
'' Largest value of ItemNum field inserted is 11
''
Set recIns = db.OpenRecordset("tblData", dbOpenDynaset, _
dbAppendOnly)
recIns.AddNew
recIns!UserID = "A"
recIns!ItemNum = intItemNum ' (ranges from 7 to 11)
etc...
recIns.Update
.... Another 99 rows ...
recIns.Close: Set recIns = Nothing
''
'' The following always returns 11 (ok)
'' (ItemNum is an integer data type that does not allow NULLS)
''
varMaxRowDiag = DMax("ItemNum", "tblData", "UserID = 'A'")
''
'' Without the delay loop, the following returns 6 (incorrect)
'' With the delay loop, the following returns 11 (ok)
''
'' (A shorter loop than below is not sufficient.)
''
varWait = DateAdd("s", 3, Now())
While varWait > Now()
Wend
Set recData = db.OpenRecordset("SELECT MAX(ItemNum) As MaxRow" & _
" FROM tblData" & _
" WHERE UserID = 'A'", _
dbOpenForwardOnly, dbReadOnly)
============================================================
============================================================
I have a situation where, depending on how data is read, rows inserted into
a table are not available for select until several seconds after the inserts
are finished.
Has anybody seen something like this before? Any ideas why I would get a
delay between the time when data is inserted and when it can be selected?
More info below.
Thanks!
Lee
More Info
==============
Steps:
(1) Import data from text file into table (140 rows)
(2) Add about 100 more rows to the table using
recordset.AddNew ... recordset.Update
(I close the insert recordset when done.)
(3) Query the data
I need to add a 3-second delay between steps 2 and 3, otherwise the select
in step 3 sees only the data imported in step 1, but not any data inserted
in step 2.
For diagnostics I have added calls to DMax() and DLookup() between steps 2
and 3. Strangely, these calls see all the data even when the select
statement that follows them does not.
Notes:
* The table is a link to an Access table in a separate .MDB file.
* Table connection is: ";DATABASE=(path)\MRData.mdb"
* I am not using replicated databases.
* I am not doing any asynchronous processing (as far as I know!)
* I am not using transactions.
* I tried using transactions as a possible fix -- no help.
* Both the code MDB and the data MDB reside in same folder.
* Both .MDB's are on my local drive.
* I have re-installed Access 97 SR-2, and Jet 3.5 SR 3
* I have repaired and compacted (again and again ...)
Code summary
============================================================
============================================================
''
'' Import 140 rows from text file for User "A".
'' Largest value of ItemNum field is 6
''
DoCmd.TransferText acImportDelim, "ImportV1", "tblData", _
strImportFile, HasFieldNames:=True
Set db = CurrentDB()
''
'' Insert an additional 100 rows
'' Largest value of ItemNum field inserted is 11
''
Set recIns = db.OpenRecordset("tblData", dbOpenDynaset, _
dbAppendOnly)
recIns.AddNew
recIns!UserID = "A"
recIns!ItemNum = intItemNum ' (ranges from 7 to 11)
etc...
recIns.Update
.... Another 99 rows ...
recIns.Close: Set recIns = Nothing
''
'' The following always returns 11 (ok)
'' (ItemNum is an integer data type that does not allow NULLS)
''
varMaxRowDiag = DMax("ItemNum", "tblData", "UserID = 'A'")
''
'' Without the delay loop, the following returns 6 (incorrect)
'' With the delay loop, the following returns 11 (ok)
''
'' (A shorter loop than below is not sufficient.)
''
varWait = DateAdd("s", 3, Now())
While varWait > Now()
Wend
Set recData = db.OpenRecordset("SELECT MAX(ItemNum) As MaxRow" & _
" FROM tblData" & _
" WHERE UserID = 'A'", _
dbOpenForwardOnly, dbReadOnly)
============================================================
============================================================