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
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