View Full Version : open a secure database using vbs


virencm
09-10-2010, 02:37 AM
hi guys
I have the following code that works and opens an access database. how do i pass my username and password to prevent the logon screen from popping up? The database uses the workgroup security.
any help would be appreciated. thanks in advance.
Cheers!

Set accDB = CreateObject("Access.Application")
accDB.visible = false
accDB.automationsecurity=1
accDB.OpenCurrentDatabase("C:\Documents and Settings\Administrator\My Documents\ltq database.mdb")
accDB.runmacro"mcrRefresh"
accDB.CloseCurrentDatabase
accDB.Quit

KenHigg
09-10-2010, 09:03 AM
In 2003 you could put them in your shortcut command line. See if this helps:

http://support.microsoft.com/kb/209207

virencm
09-11-2010, 03:41 AM
hi i can get the below code to work.. how do i add a command to run a macro after it opens access.


Set objConnection = CreateObject("ADODB.Connection")
Set accDB = CreateObject("Access.Application")
accDB.visible = false
objConnection.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=C:\Documents and Settings\Administrator\My Documents\ltq database.mdb;" & _
"Jet OLEDB:System Database=C:\Documents and Settings\Administrator\Desktop\Database\security1. MDW;" & _
"User ID=admin;Password=admin;"

KenHigg
09-11-2010, 04:13 PM
If you create a macro and name it 'Autoexec' it will run when the db opens.

virencm
09-12-2010, 06:34 PM
thanks for your help KenHigg.
cheers!

KenHigg
09-13-2010, 03:19 AM
Glad to help :)