Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 2008
    Location
    All over, Now in Missouri
    Posts
    73

    Unanswered: Clone DB Question

    pkstormy provided a VBS cloning method that works great. When the VBS clone runs, it makes a copy of the DB FE on the network drive along with the locking file. When the user leaves the Locking file disappears but the cloned FE is still there. Can I have the VBS get rid of that cloned file when they leave?

    peter

    ' My Code
    Set WshNetwork = CreateObject("WScript.Network")
    GetUser = WshNetwork.UserName
    Set WshNetwork = Nothing

    LUName = "T:\58TH\MTOC\Database\Backend\MSIS.accdb"
    'Note: or LUName = "UNC Name"
    oldname = LUName

    newName = Replace(LUName, ".accdb", "") & GetUser & ".accdb"

    retval = 0
    Dim objFSO
    Set objFSO = CreateObject("Scripting.FileSystemObject")

    retval = objFSO.CopyFile(oldname, newName, True)

    Set objFSO = Nothing

    Dim objShell
    Set objShell = CreateObject("Wscript.Shell")

    objShell****n "MSAccess.exe " & newName

    Set objShell = Nothing
    We tend to look at Linear paths which can lead us to a path of resistance!

  2. #2
    Join Date
    Dec 2004
    Location
    Madison, WI
    Posts
    3,926
    You could probably design a script which runs to delete the accdb when the user exits but I wouldn't advise it. I have it so the script clones the FE to a separate folder (which the user's don't normally access). I then look at the cloned db's to tell me when the user last opened the FE (which is always a plus for me.)

    Note though: the user must still have read/write permissions to whatever folder you have it cloned to.

    If the user exits the FE by non-normal methods, the "delete FE" script wouldn't run anyway and you'd still see the cloned FE.

    I found it doesn't pay to try and run a script when exiting the FE since if the FE locks up on the user, the script again, wouldn't run. But putting your source FE in a separate folder and having it so the script clones the FE in that folder works very nicely (ie. LUName = "T:\58TH\MTOC\Database\WorkingFEs\MSIS.accdb")

    Note also that you can put the vb script to clone/open the FE anywhere. The vb script doesn't necessarily have to be in the same folder as the FE. I put all my vb scripts in 1 folder (called DatabaseScripts) so users can easily open any FE without having to dig through the folders. You can even get fancy and design a menu type system (which can also be an accdb) to launch any vb script. I created a menu type system (but in VB).
    Last edited by pkstormy; 02-13-10 at 21:39.
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •