deleting records in a table and then adding new records 
Author Message
 deleting records in a table and then adding new records

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"
    DBtemp.Close
    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.



Sun, 01 Sep 2002 03:00:00 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. Cannot add record to Visual Foxpro table after deleting all records in table

2. ADO2.5, can't add new record to an empty table using record binding

3. adding new records & new record

4. need something like foreach record in table - add record to another table

5. Deleting Records and adding records

6. Deleting all records then adding new ones in a single update

7. How to add new record to table in external location

8. How to launch a Macro/Module when new record is added to table

9. Help with adding new record to a table.

10. word VBA won't let me add a new record to an access table

11. Adding new records to a table -- a bit confused

12. Adding a new record to a table

 

 
Powered by phpBB® Forum Software