Close down Access

  • Thread starter Andreas Andreasson
  • Start date
A

Andreas Andreasson

I have to do some events when the user close down Access. I need to copy the
datadatabase to another directory. I try to close all forms in a function. I
got an error msg - The file can not be copied. But when I close all forms
first and then call the function there is now err msg. Anybody knows why?

Public Function fAvslut()
Dim obj As AccessObject, dbs As Object
Set dbs = Application.CurrentProject
Dim fs
Set fs = CreateObject("Scripting.FileSystemObject")

For Each obj In dbs.AllForms
If obj.IsLoaded = True Then
DoCmd.Close acForm, obj.Name
End If
Next obj

MsgBox "All forms are closed - Access will quit"

fs.copyFile "C:\Documents and
Settings\Dirxxxx\Dirxxxx\filename.mdb", "f:\Dirxxx\Dirxxxx\filename.mdb"
fs.deletefile "C:\Documents and
Settings\Dirxxxx\Dirxxxx\filename.mdb"

DoCmd.quit
End Function
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top