VBS to point to shortcut to open access

mleiser

Registered User.
Local time
Today, 02:12
Joined
May 18, 2010
Messages
12
Hi! I have a MS Access 2003 split database with user level security. I use a shortcut to open the database in order to facilitate logging (I'm not sure why it has to be this way).

I want to use the following VB code to clone the frontend upon login, but I can't figure out how to get the script to open the shortcut.

The actual database filename is Merchandising.mdb; the short cut to get in is login_merchandising.mdb

Can anyone assist?

Here is the shortcut details:
"C:\Program Files\Microsoft Office\OFFICE11\MSACCESS.EXE" "F:\Buying\AccessDatabase\Merchandising.mdb" /WRKGRP "F:\Buying\AccessDatabase\Security.mdw"

Here is the VB code:


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

LUName = "F:\Buying\AccessDatabase\Merchandising.mdb"
'Note: or LUName = "UNC Name"
oldname = LUName

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

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.Run "MSAccess.exe " & newName

Set objShell = Nothing
 
Last edited:

Users who are viewing this thread

Back
Top Bottom