Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Is there a way to save a copy of the database when the db is closed

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
I want to know if there is a way I can save a copy of the database when the user closes it. Or how do i put a database over the network of about 5 computers?

Thanks
 
Being an old "DOS" guy, I first wrote a simple batch file, named it "backup.bat" and put only one line into it:

copy s:\access.mdb s:\access_backup\access.mdb

Simply translated, I'm copying an access database from the network "S" drive to a backup subdirectory on the same drive. You need write this using your own DriveLetter:\Directory\DatabaseName.mdb

Then, in your "On Unload" event of your form, you need insert the code:

Private Sub Form_On_Unload()
Dim stAppName As String
stAppName = "s:\backup.bat"

Call Shell(stAppName, 0)
End Sub
 
Sounds good, what's "shell" in "call shell" statement?
 
"Shell" is a Microsoft Access Function. The following is quoted exactly from the Help facility from within Access. You can refer to it for any further usage instructions or clarification.

From Microsoft Access Help utility, and I quote:

Runs an executable program and returns a Variant (Double) representing the program's task ID if successful, otherwise it returns zero.

Syntax

Shell(pathname[,windowstyle])

The Shell function syntax has these named arguments:

pathname
Required; Variant (String). Name of the program to execute and any required arguments or command-line switches; may include directory or folder and drive. On the Macintosh, you can use the MacID function to specify an application's signature instead of its name. The following example uses the signature for Microsoft Word: Shell MacID("MSWD")

windowstyle
Optional. Variant (Integer) corresponding to the style of the window in which the program is to be run. If windowstyle is omitted, the program is started minimized with focus. On the Macintosh (System 7.0 or later), windowstyle only determines whether or not the application gets the focus when it is run.
 
fratus thanks. That is just great. I used it onunload of the form. I appreciate your help very much.

Now I wonder: is there a way of activating the batch file, on exiting the whole application? and not when a form is closed?

If not, I'll just use it for each of the forms on unload event.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top