Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Open another database from current database security issues 1

Status
Not open for further replies.

juddymarch

Technical User
Aug 10, 2007
17
Hi, I currently have a database (Which I didn't create) that contains a listbox of access database names and locations in which a user can select one and then click an open button to open that particular database. The file is opened by using the following code.

Dim varDatabaseLocation As String
If IsNull(Me.lstboxDatabases.Column(1)) Or (Me.lstboxDatabases.Column(1)) = "" Or IsNull(Me.lstboxDatabases.Column(2)) Or (Me.lstboxDatabases.Column(2)) = "" Then
MsgBox "The database does not exist or the link is not correct" & vbCrLf & vbCrLf & _
"Please contact the BMS Administrator for further information", , "File not available"
Exit Sub
End If
DoCmd.Hourglass True
varDatabaseLocation = Me.lstboxDatabases.Column(2) & Me.lstboxDatabases.Column(1)

Application.FollowHyperlink varDatabaseLocation ', , True

DoCmd.Hourglass False

Basically a path and mdb file name is passed into application.followhyperlink. The problem I have now is that one of the database's I need to open contains a different workgroup file with security. I need to pass in the workgroup file location name along with the password and username.
Im just wondering if this can be done? I have spent the last hour searching and haven't been able to find anything to help me.
Any advice help would be greatly appreciated.
Thanks
Justin
 
You could use Shell
Code:
Sub OpenSecuredMDBFile ()
Dim myShell As String
Dim strAccessExe As String
Dim strMDB As String
Dim strMDW As String
Dim strUser As String
Dim strPassword As String

strAccessExe ="C:\Program Files\Microsoft Office\OFFICE11\MSACCESS.EXE" 
strMDB = "C:\ProjectOffice\ProjectOffice.mdb"
strMDW = "L:\ProjectOffice\DataBase\ProjectOffice.mdw"
strUser = "TheMaster"
strPassword = "TheSecretPassword"

myShell = Chr(34) & strAccessExe & Chr(34) & " " & _
          Chr(34) & strMDB & Chr(34) & " /wrkgrp " & _
          Chr(34) & strMDW & Chr(34) & " /user " & _
          Chr(34) & strUser & Chr(34) & " /pwd " & _
          Chr(34) & strPassword & Chr(34)

Shell myShell
End Sub

That way you could include any other command line start up options
 
Thanks for the reply JerryKlmns. It appears to be exactly what I'm after, I will try your code later today or early tomorrow and let you know how I go (and give you a star of course:))
Thanks
Justin
 
JerryKlmns, Thankyou It works perfectly:) have a star
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top