Results 1 to 6 of 6
  1. #1
    New Lounger
    Join Date
    May 2006
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Connecting to a Library Using VBA (w/PW) (Microsoft Access 2002)

    Hello Everyone!
    I have already been connecting MS-Access VBA library references (e.g. DAO360.dll; msado21.tlb, etc) using VBA. But what I want to do now is reference a MS-Access database MDE in the library using VBA. Problem is that my MDE has a database password. It connects correctly, however you must enter the password. I don't want other folks who use this to have to type the password.

    Any ideas??

    Thanks!!

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Connecting to a Library Using VBA (w/PW) (Microsoft Access 2002)

    Do you have a specific reason for wanting to do this in code?

  3. #3
    New Lounger
    Join Date
    May 2006
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Connecting to a Library Using VBA (w/PW) (Microsoft Access 2002)

    Yes //
    It's easier to release 1 mde, and reference it to use it's resources in a copy. This way you can control revisions/releases in a single instance of an mde, while protecting the data from misguided people. See my flow chart attachment. *And thanks for looking at this Hans!

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Connecting to a Library Using VBA (w/PW) (Microsoft Access 2002)

    I'd try installing the mde in a fixed location, so that you don't have to set or change the reference. I can't find anything about setting a reference to a password-protected database in code.

  5. #5
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Connecting to a Library Using VBA (w/PW) (Microsoft Access 2002)

    You can set references in code, although it can be a pain in the neck to do so. Iit requires a reference to the VBE6 library, it has to be in a separate module with no other code routines besides those related to setting the references, and it needs to be run at application startup before any other code is called. Here's some code from the XP developer's code librarian that I think you should also be able to find in online help ... somewhere.

    <pre>Function SetReference(vbpProject As VBIDE.VBProject, _
    strReference As String, _
    Optional lngMajor As Long, _
    Optional lngMinor As Long) As Boolean
    ' Sets reference within specified project from GUID or file name.

    On Error GoTo SetReference_Err

    If IsGUID(strReference) Then
    vbpProject.References.AddFromGuid strReference, lngMajor, lngMinor
    Else
    vbpProject.References.AddFromFile strReference
    End If
    SetReference = True

    SetReference_End:
    Exit Function

    SetReference_Err:
    Select Case Err.Number
    Case 32813
    ' Reference is already set, so resume next and return True.
    Resume Next
    Case Else
    StandardError Err
    End Select
    SetReference = False
    Resume SetReference_End
    End Function</pre>

    Charlotte

  6. #6
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Connecting to a Library Using VBA (w/PW) (Microsoft Access 2002)

    Sorry, I just realized you're probably already using code like I posted, and it doesn't address the issue of passwords. I can't help you with that, since I don't see much point in putting a password on an MDE in the first place. The code and forms can't be modified by anyone anyhow, since the is no code and there are no permissions on the forms.
    Charlotte

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •