2.I'VE ALREADY BACKUP MY TABLES INTO TXT FILES. NOW I WANT TO RESTORE IT TO MY MDB,(unzip it)
BUT I WANT THE PROGRAM TO CHECK IF THE TABLE EXIST IN THE DATABASE,IF NOT THEN CREATE THE TABLE.
IF THE TABLE EXIST THEN THE PROGRAM compare the data in the txt files and the tables and update
the records that are different only, if the records is the same then do nothing. also append new
records if there is.
anyone knows the code? thank you.
I think you need to take a step back and look at this from a different angle.
This sounds like a job for SQL Server. SQL Server is much better at handling backup and restore issues. I.E. the tools are already available and you will not need to reinvent these tools.
Having said that, most access databases are small (up to a few hunderd megs 2 gigs max depending on the edition of Access). To make your life easier, you should look at your backup requirements and if they are not too critical (i.e. losing up to a day's data is ok etc.) then you are better off backing up the entire database file instead. If there is a problem during the day you can restore the file with a simple copy and paste.
To address your question, check to see if the table exists, you will need to use DAO and the tabledef's collection or ADOX object model. Then use an append query to append ALL records from the text file back into that table. Access will detect records that already exist based on the key and append only the records that do not exist. the rest goto a table called paste errors.
Another approach will also involve code. You will need to step through the text file linked to access and do individual checks and inserts. this method is slower but you will see less access triggered messages (I.E. "access was able to append 10 records and rejected 3 bla bla bla")