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

    current db with pwd (Access 2000)

    How to open the current database with password


    I have a succesful code to open another database which runs as follows:

    Dim StrPassword As String
    StrPassword = "secret"
    Dim db As DAO.Database
    Set db = DBEngine.Workspaces(0).OpenDatabase("C:bebe.mdb ", dbDriverComplete, False, "; PWD=" & StrPassword)


    However i want to rewrite the code so that it opens not an external but the current database.
    I tried to replace the path with the words CurrentDB but it didnt work.May i know where is my fault?

    This code is written in the autoxec code of a dtatabase that is protected with a password.

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

    Re: current db with pwd (Access 2000)

    Sorry, but I'm not quite sure what you're doing. CurrentDb is the one you're in right now. You can't open it again from inside because you don't need to. What are you actually trying to accomplish?
    Charlotte

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

    Re: current db with pwd (Access 2000)

    Thank you for your reply. If you disregard the end use of my cod because i will bother you with my lenfgthy explanation,, could you show me what is wrong with my code? When i debug it it shows "Type mismatch". It think i am committing some grave mistake somewhere.
    it is as follows

    Dim StrPassword As String
    StrPassword = "secret"
    Dim db As DAO.Database
    Set db = DBEngine.Workspaces(0).OpenDatabase(CurrentDb, dbDriverComplete, False, "; PWD=" & StrPassword)

    Bes Regards !

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

    Re: current db with pwd (Access 2000)

    I suspect it's because the first argument is expected to be a string that contains the path of the database. CurrentDb returns an object pointer to the database that you are presently in. If you explain what you're trying to accomplish, maybe someone can help you, but it isn't going to work the way you're going about it.
    Charlotte

  5. #5
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Edmonton, Alberta, Canada
    Posts
    326
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: current db with pwd (Access 2000)

    As Charlotte said (approximately) - What's the point? The database is already open.

    That said, if you really want to do what you seem to be trying, change CurrentDb to CurrentDB.name.

Posting Permissions

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