I am accessing an Access database table via a VB program and displaying its
records in a data grid on a form. One of my procedures consists of deleting
all the records of this particular table in the database , and immediately
repopulating the table with new records.
My problem is that occasionally, the repopulated table does not display,
say, the first 20 of its records in the data grid view. But when I check the
table in Access all the new records are there. But there is a catch: the
table is really corrupted, for if you "repair" the database, this table now
only contains the fewer number of records that were displaying the in the
repopulated data grid.
I delete the records with the following code:
Dim DBtemp As dao.Database
Set DBtemp = OpenDatabase(WF) 'the working file
DBtemp.Execute "delete * from invoices_pending"
Set DBtemp = Nothing
and then immediatly repopulate the table via more code.
Could my problem be that the above deletion process doesn't finish before
the repopulation starts, resulting in the first 20 ro so new records not
really being recorded?
This is a bit hard to debug, since the problem occurres erratically. I have
put a pause in between the deletion and repopulation of the table, and it
seems to cure the problem. But I have thought that I had the problem cured
before only to have it come back.