Is there any code that will close the db and same can be copeid samewhere?

Ashfaque

Search Beautiful Girls from your town for night
Local time
Today, 11:52
Joined
Sep 6, 2004
Messages
897
Hi,

I am looking for the code that will close the current db and copy the same db to a particular folder.

Is there anything like?

Regards,
Ashfaque
 
Why do you need? I have code that checks for version and if there is newer, copies revised frontend to user local drive. Worked until IT modified permissions so files can no longer be programmatically copied.
Code:
Private Sub Form_Load()
       
'Check for updates to the program on start up - if values don't match then there is a later version
If Me.tbxVersion <> Me.lblVersion.Caption Then
    'because administrator opens the master development copy, only run this for non-administrator users
    If DLookup("Permissions", "Users", "UserNetworkID='" & Environ("UserName") & "'") <> "admin" Then
        'copy Access file
        CreateObject("Scripting.FileSystemObject").CopyFile _
            gstrBasePath & "Program\Install\MaterialsDatabase.accdb", "c:\", True
        'allow enough time for file to completely copy before opening
        Dim Start As Double
        Start = Timer
        While Timer < Start + 3
            DoEvents
        Wend
        'load new version - SysCmd function gets the Access executable file path
        'Shell function requires literal quote marks in the target filename string argument, apostrophe delimiters fail, hence the quadrupled quote marks
        Shell SysCmd(acSysCmdAccessDir) & "MSAccess.exe " & """" & CurrentProject.FullName & """", vbNormalFocus
        'close current file
        DoCmd.Quit
    End If
Else
    'tbxVersion available only to administrator to update version number in Updates table
    Me.tbxVersion.Visible = False
    Call UserLogin
End If

End Sub
 
Thanks June7,

This kind of code I have and working very well. This code is to use on open startup form that will check the newer version and will pick the newer version from a perticular folder. I need the code lines to copy the db to that particular folder once I modify the working db

But the problem is such kind of vba code that will run at db closing time and once db closed nothing will be executed.

So it might be done from other db to copy the required db copying and storing somewhere.

Any other thought?
 
Why?,
Just wait until the user opens their FE, and then copy it then?
 
Sounds like you just need a backup procedure.
To ensure it runs before closedown, add it to the Form_Unload event of a hidden form that loads at startup & runs in the background whilst your databasse remains open. This guarantees the procedure will be the last code to run before the app closes (unless it crashes or is closed forcibly)
If you only want it to run when your database changes, then use a boolean variable as a flag to indicate whether or not the backup needs to be run.
However, is it really worth all that effort? Just save a backup copy when you make changes
 

Users who are viewing this thread

Back
Top Bottom