how to backup database using visual basic

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

i like to add a command button to my database that when clicked, it creates a
backup or compact the data base and then closes the database,
 
K. Shoghi said:
i like to add a command button to my database that when clicked, it creates a
backup or compact the data base and then closes the database,


As stated, this is not a viable idea. A database is a very
dynamic data repository and you have very little control
over its I/O activities. A copy of an open file may very
well be unusable.

As for compacting, Access has an option to Compact On Close.
Personally, I do not feel comfortable using this option
because it is such a heavy duty operation (potentially
rearranging every byte in the file) that I feel that making
a backup to be a very important first step.

The situation is more complex if you have split your
application into two mdb files, the frontend with form's
reports, queries and modules and the backend data tables.
Unless you have a fairly poor design, the front end should
have almost no need to backup or compact. The important
part is the back end data tables. If you can determine when
the back end is not being used by anyone, then it would be
safe to perform these operations if you are very careful in
your VBA procedure to lock out other users and recover if
you can not get exclusive access to the back end.

Personally, I think you should use a reliable, independent
backup procedure that includes a verification that the
backup copy is actually usable before proceeding with other
maintenance activities.
 
Back
Top