Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 15th, 2006, 01:23 AM
Authorized User
 
Join Date: Feb 2006
Posts: 53
Thanks: 0
Thanked 0 Times in 0 Posts
Default Connecting to workgroup protected database

Hi I am trying to connect from an Access application to another Access mdb database file. I have got the workgroup set up, with the user "myself" granted full access to this protected database. However, I keep getting the following error:

"Cannot start your application. The workgroup information file is missing or opened exlusively by another user."

Can someone help me with this?
I have the error persisted no matter whether I am currently logged into the workgroup or the default workgroup.

My code is as follows:

///////////////////////////////////////////////////////////////////
Dim conRemote As New adodb.Connection
Dim strCon as string

strCon = "Provider = Microsoft.Jet.OLEDB.4.0; " & _
"Data Source = RemoteData.mdb; User Id =myself; Password = password;"

conRemote.Open strCon
///////////////////////////////////////////////////////////////////



Scripts82
__________________
Scripts82
 
Old February 15th, 2006, 07:19 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,093
Thanks: 1
Thanked 12 Times in 11 Posts
Default

Hello,

You need to tell your connection object where the workgroup information file is located as well:

Code:
Sub ConnectToSecuredMDB()
   Dim cnn As ADODB.Connection
   Dim rst As ADODB.Recordset
   Dim strSQL As String

   On Error GoTo Err_Handler

   Set cnn = New ADODB.Connection
   With cnn
      .Provider = "Microsoft.Jet.OLEDB.4.0"
      .Properties("Data Source") = "C:\SecuredDatabase.mdb"
      .Properties("Jet OLEDB:System Database") = "C:\WorkgroupInformationFile.mdw"
      .Properties("Mode") = adModeShareDenyNone
      .Properties("User ID") = "John Doe"
      .Properties("Password") = "John"
   End With
   cnn.Open

   strSQL = "SELECT * FROM tblRecords"

   Set rst = New ADODB.Recordset
   rst.Open strSQL, cnn, adOpenForwardOnly, adLockReadOnly, adCmdText
   Debug.Print rst.GetString(adClipString, , ";")

   rst.Close
   cnn.Close

   Set rst = Nothing
   Set cnn = Nothing

   Exit Sub

Err_Handler:

    If Not rst Is Nothing Then
        If rst.State = adStateOpen Then rst.Close
    End If
    Set rst = Nothing

    If Not cnn Is Nothing Then
        If cnn.State = adStateOpen Then cnn.Close
    End If
    Set cnn = Nothing

    If Err <> 0 Then
        MsgBox Err.Source & "-->" & Err.Description, , "Error"
    End If

End Sub
HTH,

Bob

 
Old February 15th, 2006, 10:28 AM
Authorized User
 
Join Date: Feb 2006
Posts: 53
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks! Got that after some searching on the net too...

Scripts82





Similar Threads
Thread Thread Starter Forum Replies Last Post
Connecting to Database bryantms ASP.NET 3.5 Basics 3 July 9th, 2008 12:34 AM
connecting to database stealthdevil Visual Basic 2005 Basics 2 November 5th, 2007 01:31 PM
sub report in a password protected access database aasheesh_jha Crystal Reports 0 January 2nd, 2007 07:09 PM
Connect to password protected Database abhisheksud ASP.NET 1.0 and 1.1 Basics 2 October 7th, 2005 04:43 PM
database connecting princeofdhump Classic ASP Databases 3 August 7th, 2004 02:46 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.