Results 1 to 13 of 13
  1. #1
    2 Star Lounger
    Join Date
    Nov 2001
    Posts
    192
    Thanks
    0
    Thanked 0 Times in 0 Posts

    open db from another db (Access 2000)

    Open a database from another database
    is it possible to open a database protected with a password from another database? I want to build a code that opens a database,and supplies the necessary password,from another database.

  2. #2
    Bronze Lounger
    Join Date
    Nov 2001
    Location
    Arlington, Virginia, USA
    Posts
    1,394
    Thanks
    0
    Thanked 3 Times in 3 Posts

    Re: open db from another db (Access 2000)

    One option is to use DAO OpenDatabase method. Example:
    <pre>Function TestOpenPwdDatabase()
    On Error GoTo Err_Handler

    Dim ws As DAO.Workspace
    Dim db As DAO.Database
    Dim tbl As DAO.TableDef

    Set ws = DBEngine.Workspaces(0)
    Set db = ws.OpenDatabase("C:LOGIN.mdb", False, False, "MS Access;PWD=123XYZ")

    For Each tbl In db.TableDefs
    Debug.Print tbl.Name
    Next tbl

    db.Close
    ws.Close

    Sub_Exit:
    Set ws = Nothing
    Set db = Nothing
    Set tbl = Nothing
    Exit Function
    Err_Handler:
    MsgBox "Error " & Err.Number & ": " & Err.Description
    Resume Sub_Exit

    End Function
    </pre>

    You have to supply the optional Options and Read-Only arguments (can just use "False") for OpenDatabase method or this won't work, you'll get error message "Not a valid password." There's no way I know of to provide password string if using TransferDatabase to import or link tables.
    HTH

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

    Re: open db from another db (Access 2000)

    It depends on what you're trying to do. Do you want to open an unprotected database and have it open a protected one so you can work in the protected one, or are you just trying to get data out of the protected one into the unprotected database?

    Keep in mind that the purpose of the password is to keep unauthorized persons from opening a database. If you create a means of getting into it without the password, you have just invalidated the protection on the other database. I personally wouldn't do that.
    Charlotte

  4. #4
    2 Star Lounger
    Join Date
    Nov 2001
    Posts
    192
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: open db from another db (Access 2000)

    thank you for your reply.I am trying to get data out of the protected on into the unprotected database.I agrre with what you write about the protection it is just a special case where i need it and if you are interested i may send the explanation to you,however i am afraid i may be boring.How shall i proceed in my case to get data out of the protected database?

    Kind regards

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

    Re: open db from another db (Access 2000)

    You can create a workspace to open a session on the other database and pass the username and password in there:

    Set wsp = DBEngine.CreateWorkspace("", strUser, strPwd, dbUseJet)

    This assumes that the database in question is a Jet database, of course. I've used strUser and strPwd to represent variables containing the username and password you need to pass in.

    The you open the remote database like this:

    Set dbs = wsp.OpenDatabase("F:Protected.mdb",False)

    You would substitute the correct path and filename for what I put in here.

    After that, you can open recordsets on the protected database and use them to write data into recordsets opened on the CurrentDb.
    Charlotte

  6. #6
    2 Star Lounger
    Join Date
    Nov 2001
    Posts
    192
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: open db from another db (Access 2000)

    A perfect answer. I feel obliged to express my gratitude since this was so important to me.
    Thank you very much !

  7. #7
    5 Star Lounger
    Join Date
    Feb 2001
    Location
    Louisville, Kentucky, USA
    Posts
    605
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: open db from another db (Access 2000)

    Charlotte,

    I've tried to find a work around for this situation a few times w/o success, until now. However, I'm still a little lost.....

    If the db I'm trying to EXPORT from is password protected, I would still need to know the password wouldn't I? And If I did know the password, what's the point in the code you offered? Or is your solution suggesting you wouldn't need to know the user name and password? If the latter is correct, could you offer a little more explanation of the code you provided, as it seems to me that setting the variable would still require knowing the password in the first place.

    As you know, I'm a still a little dense when it comes to code so please forgive me for asking what might seem to be silly questions.

    Thanks in advance,
    Roberta Price <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16>

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

    Re: open db from another db (Access 2000)

    The question was how to open a password protected database from another database, nothing else. To export from a database, you have to have it open and you wouldn't be using code like this at all.
    Charlotte

  9. #9
    5 Star Lounger
    Join Date
    Feb 2001
    Location
    Louisville, Kentucky, USA
    Posts
    605
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: open db from another db (Access 2000)

    Charlotte,

    I realize what the original question was, I however, was asking a similar question in regards to the password, I'm sorry if i didn't make myself clear. This post was the first post I've seen close enough to my situation so I stuck my nose in and only asked you because you had the solution to the password issue. PASSWORD PROTECTED DB was what caught my eye. If I'm out of line, then I apologize.

    I was wanting to know if there was a way of EXPORTING objects from a password protected db w/o knowing the password. I know the code for exporting and importing, what I don't know is how to do it when the password is unkown.

    And as always, thanks for your help.



    ps....the code you provided still seems to suggest the username and password must be known in the code. Just curious.
    Roberta Price <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16>

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

    Re: open db from another db (Access 2000)

    Roberta,

    You aren't out of line, but the code posted had nothing to do with an export, so your question confused me. Exports are done from within the database. That means you have to be able to open a database in order to Export, and that means you have to know the password in order to get there. There's not much point in a password if anyone can come along and get around it. <img src=/S/shrug.gif border=0 alt=shrug width=39 height=15>
    Charlotte

  11. #11
    5 Star Lounger
    Join Date
    Feb 2001
    Location
    Louisville, Kentucky, USA
    Posts
    605
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: open db from another db (Access 2000)

    Let me try this...if I may.

    In the forgein db I want to import objects from a password protected db, I don't know the password, can this be accomplished?
    Roberta Price <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16>

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

    Re: open db from another db (Access 2000)

    Well, *I* don't know how. I suppose there might be a password cracker that would allow you to do it, but it is bad manners and can get you into legal trouble with whoever actually owns the protected db.
    Charlotte

  13. #13
    Platinum Lounger
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    4,594
    Thanks
    0
    Thanked 27 Times in 27 Posts

    Re: open db from another db (Access 2000)

    Tut tut Roberta, but then again anything is possible.
    But as Charlotte says, be very careful.

Posting Permissions

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