• current db with pwd (Access 2000)

    Author
    Topic
    #372364

    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.

    Viewing 0 reply threads
    Author
    Replies
    • #595080

      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?

      • #595089

        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 !

        • #595093

          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.

        • #595267

          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.

    Viewing 0 reply threads
    Reply To: current db with pwd (Access 2000)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: