Page 1 of 2 12 LastLast
Results 1 to 15 of 25
  1. #1
    Join Date
    Jul 2006
    Posts
    11

    Arrow Unanswered: Password Protection on a form.

    Hi,

    i am tasked to do a password protection on a form for my database.
    im using MS Access 2000.

    Can anyone help me on how to go about doing this password protection thing??

    i hope you could reply back to me asap coz ma dataline is coming soon.

    thank you.


    ::musicgerl::

  2. #2
    Join Date
    Dec 2005
    Location
    Somewhere on the 3rd Rock
    Posts
    93

    Coding

    here is a simple code if security is not a big deal! Just put in the OnOpen Command

    Code:
    Private Sub Form_Open(Cancel As Integer)
    
    Dim pwd As String
    pwd = InputBox("Enter the Password")
    If pwd = "Your Password here" Then
    MsgBox "Password Correct"
    Else
    MsgBox "Incorrect Password!!"
    DoCmd.Close
    End If
    
    End Sub
    you can change the InputBox and the MsgBox wording. and change "Your Password here" to your password.
    Last edited by saileast; 07-26-06 at 23:01.
    Will Dove
    working hard is better then hardly working ...

  3. #3
    Join Date
    Jul 2006
    Posts
    11
    Hi saileast,

    i have a qn for u.
    dont u need to create a form for the user to enter their password?
    coz i have done a password form prompt for the user to enter thier password.
    and where shld i put the code that you gave earlier??

    thanks

    ::musicgerl::

  4. #4
    Join Date
    Dec 2005
    Location
    Somewhere on the 3rd Rock
    Posts
    93
    Just open the form you want to protect in the design view. Once it is open select the form properties, then choose the Event tab, and look for the On Open selection. set it to [Event Procedure] then click on the ... tab next to the box. this will open the VBA code builder. the cursor will be in the proper place,

    you should see this

    Code:
    Option Compare Database
    
    Private Sub Form_Open(Cancel As Integer)
    
    End Sub
    you will need to place the following code after Private Sub Form_Open(Cancel As Integer)
    Code:
    Dim pwd As String
    pwd = InputBox("Enter the Password")
    If pwd = "Your Password here" Then
    MsgBox "Password Correct"
    Else
    MsgBox "Incorrect Password!!"
    DoCmd.Close
    End If
    and before End sub
    Will Dove
    working hard is better then hardly working ...

  5. #5
    Join Date
    Jul 2006
    Posts
    11
    thanks saileast

    the code works well!!!

    erm...i got another qn for you.
    how can i make the password ***** by using the VBA code??
    and on that same form i only want one particular user to enter the password while other user will only open the form by using Read-Only. So how can i achieve this?

    in other words, do u know the code for read-only??

    thanks

    ::musicgerl::
    Last edited by musicgerl; 07-26-06 at 23:45.

  6. #6
    Join Date
    Dec 2005
    Location
    Somewhere on the 3rd Rock
    Posts
    93
    A simple way to do this is to setup a duplicate form to the one you are trying to protect. Once you get it copied go in and change all the text fields to Enabled No, and Locked Yes... This will in effect make the form read only. THere are other ways to do this, but require more coding. I am fairly new at coding the VBA side of Access, and only know a few tricks.

    Once you have that set up you can go in and change the orginal code I gave you to protect the form. You just need to add one line of code to it.

    in the code you will see DoCmd.Close you need to add this on the next line DoCmd.OpenForm ("form Name")

    The form name should be the same as the form you duplicated and and disabled and locked the fields on. When I did this I named the duplicate the same thing as the orginal form but added RO to the end of the form name. Then save every thing. As for the "****" mask for the password I am not sure how to change the format.
    Last edited by saileast; 07-27-06 at 04:03.
    Will Dove
    working hard is better then hardly working ...

  7. #7
    Join Date
    Jul 2006
    Posts
    11
    den how can i make the password ***** by using VBA code???

  8. #8
    Join Date
    Jul 2006
    Posts
    108
    if you want a username and password you can use this script i just designed (first one, i know no VB at all so this is a major improvement for me)

    thanks to saileast for the orginal script

    Code:
    Dim user As String
    Dim pwd As String
    user = InputBox("username")
    pwd = InputBox("Password")
    If pwd = "password" And user = "user" Then
    MsgBox "Access Granted"
    Else
    MsgBox "Incorrect Login"
    DoCmd.Close
    End If
    change the text in red to the username and password you want

    im still making some improvements for it so check back later.

  9. #9
    Join Date
    Jul 2006
    Posts
    11
    thanks jwalker343 for the code.

    but wat i need is just a password prompt for the user. i dont need the username n stuff..

    btw how do u make the password ***** by using the VB code. i noe there's a way of changing it by using the input mask. but rite now the form for password prompt is created by MS Access itself. so i couldnt modify the form.

    and one last thing, i still couldnt get the Read-Only method. can anyone simplify it in a simplest form where i can easily understand.

    thanks for all your help

    ::musicgerl::

  10. #10
    Join Date
    Jul 2005
    Posts
    144

    Cool Hope this helps

    Hi Musicgerl,

    how can i make the password ***** by using VBA code???

    You can go to the table which has the password field and click in that field where on the right side you will see a button click on that, which is the properties of that field in there you will see an option with ** (password) in it just choose that.
    That should take care of your problem.

  11. #11
    Join Date
    Jul 2006
    Posts
    108
    ^^wont work, were not bound to a table with passwords, you could set it up to open a form and blah blah blah


    ive tried to get the damn password field working right but i just cant, i have no clue how to do the **'s
    Last edited by jwalker343; 07-28-06 at 12:52.

  12. #12
    Join Date
    Jul 2006
    Posts
    108
    sorry for this but for some reason i cant edit my post


    please see here:

    http://www.dbforums.com/showthread.p...utbox+password

  13. #13
    Join Date
    Jul 2006
    Posts
    11
    thanks jwalker343.

    i still couldnt solve dis input mask thing!! arrrggggg!!! someone help me pleasseee!!!

    how to make d password ***** without using the input mask properties as my password promt form is created by MS Access itself.

    help me pleasssseee!!!!

    thanks

    ::musicgerl::

  14. #14
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Quote Originally Posted by musicgerl
    how to make d password ***** without using the input mask properties as my password promt form is created by MS Access itself.
    Hi

    Not possible I'm afraid (or at least far too hard for me!). You'll need to create an input of your own. Attached is an example of a bespoke dialog box. You will need to change the input mask for the textbox to Password.

    Quote Originally Posted by musicgerl
    and one last thing, i still couldnt get the Read-Only method. can anyone simplify it in a simplest form where i can easily understand.
    How about
    Me.AllowEdits = False
    to make the form read only and True for normal editing?

    HTH
    Attached Files Attached Files
    Testimonial:
    pootle flump
    ur codings are working excelent.

  15. #15
    Join Date
    Dec 2005
    Location
    Somewhere on the 3rd Rock
    Posts
    93
    Quote Originally Posted by pootle flump
    How about
    Me.AllowEdits = False
    to make the form read only and True for normal editing?

    HTH
    Can you explain this Pootle Flump I would like to know more about this.

    Thanks
    Will Dove
    working hard is better then hardly working ...

Posting Permissions

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