Have you ever tried to make a shortcut to launch/open an MS Access database and had an error returned because the Target string was too long? Or do you simply need more control/flexibility from your launching routine. In that case, a VBScript is the ideal way to go. Below is the most basic format that the VBScript can take. Simply alter the Script Variables, Save and execute!
I have made the following as flexible as possible so it can open simple database files, as well as security enabled database. It is simply a question of assigning values to the Script Variables or not.
I truly hope this helps you out!
'******************************************************************************* 'Date: 2008-05-27 'Author: Daniel Pineault / CARDA Consultants Inc. ' http://www.cardaconsultants.com 'Copyright: You are free to use the following code as you please so long as ' this header remains unaltered. 'Purpose: Launch the specified access database 'Revision: 2008-05-27 Initial Release '******************************************************************************* Dim sAcc Dim sFrontEnd Dim sSec Dim sUser Dim objShellDb Dim sComTxt 'Script Configuration Variable '******************************************************************************* 'Specify the Fullpath and filename of the msaccess executable sAcc = "C:\Program Files\Microsoft Office\OFFICE11\msaccess.exe" 'Specify the Fullpath and filename of the database to launch sFrontEnd = "D:\Main\My Documents\TestDb.mdb" 'If your database is secured by an mdw file specify it below, otherwise 'leave its value blank sSec = "C:\Databases\Security.mdw" 'If your database is secured by an mdw file and you want to specify the 'username to use specify it below, otherwise leave its value blank sUser = "" '******************************************************************************* '******************************************************************************* 'You should not need to edit anything below this point '******************************************************************************* '******************************************************************************* 'Launch database '******************************************************************************* Set objShellDb = CreateObject("WScript.Shell") 'Build the command to launch the database sComTxt = chr(34) & sAcc & chr(34) &_ " " & chr(34) & sFrontEnd & chr(34) if isNull(sSec)=False AND sSec<>"" Then sComTxt = sComTxt & " /wrkgrp " & chr(34) & sSec & chr(34) End if if isNull(sUser)=False AND sUser<>"" Then sComTxt = sComTxt & " /user " & sUser End if objShellDb.Run sComTxt 'Launch the database

Tuesday, September 14th, 2010, 4:29 pm | 


September 14, 2010 at 6:38 pm
Thank you for this post. I been trying to find out how-to accomplish exactly this and haven’t been able to find a clear and concise example, well, until I came across your excellent website.
Thank you! Thank you! Thank you!
February 1, 2011 at 3:44 am
Dan you are a legend
I needed this for my citrix environment and it works a treat.
Thanks alot man.
February 1, 2011 at 3:02 pm
I don’t know about being a legend, but I like a lot of other people out here (online) just enjoy being able to share our knowledge and help others out! If I can pass along some of what I have learnt the long and hard way so that others in similar situations can be spared the time and frustrations, and given a leg up on their work, it is my pleasure to do so.
Thank you for your feedback. I truly appreciate knowing that this site is useful and worth my energies.
February 10, 2011 at 2:03 am
Dan that is a very gracious attitude and I hope it rubs off onto more people.
Do you have any knowledge on how to set the macro security level in access to low using your script?
I have previously been able to set the security through other means (shown below), but I’m not sure how to combine that functionality with your script..
Set oAccess=Createobject (“Access.Application”)
oAccess. automationsecurity=1
oAccess.opencurrentdatabase “Database.mdb”
February 10, 2011 at 11:47 am
I’m afraid i do not. Furthermore, it would defeat the purpose of such security if you could merely change it using standard coding. Your best bet would bet to post your question on the http://social.answers.microsoft.com/Forums/en-US/addbuz/threads?filter=mf%3a6edab96e-a4cc-4ccb-ae44-7bcdb5ffa589%2calltypes forum. Give as much detail as possible, explain what you are trying to accomplish, and even the why you are trying to do it and people will offer you solutions to your question.
November 15, 2011 at 6:18 pm
Fan-Tastic. I have an awful old MS Access DB that needs to be running on my server, but sometimes it chokes, so I needed a nice script to kill it and restart it.
This started it up perfectly. Thank you!
-dan