1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Access: Password protect a form?

Discussion in 'Business Applications' started by cliffrose, Aug 19, 2009.

Thread Status:
Not open for further replies.
Advertisement
  1. cliffrose

    cliffrose Thread Starter

    Joined:
    Jan 21, 2006
    Messages:
    46
    Hi all,

    i have one form I'd like to password protect. I found the following code online that I know will work:

    In ON CLICK event
    Dim PassWord As String
    PassWord = InputBox("Enter Password")
    If PassWord = "YourPassword" Then
    ' Open Form
    DoCmd.OpenForm "YourFormName"
    DoCmd.GoToRecord , , acNewRec
    Else
    MsgBox ("You're not authorized")
    End If

    but the problem is that this is tied to a button on the switchboard. I have 5 different switchboard pages, and if i tie this to the first button on the physical form (in the form section), I think it will require the password for the first button on all the pages.

    is there a workaround or another way to do this?

    TIA,

    E
     
  2. OBP

    OBP

    Joined:
    Mar 8, 2005
    Messages:
    19,895
    E, if you put that in the Form's "On Load" Event Procedure and change it t0
    Dim PassWord As String
    PassWord = InputBox("Enter Password")
    If PassWord = "YourPassword" Then
    ' Open Form
    exit sub
    Else
    MsgBox ("You're not authorized")
    DoCmd.Close acForm, Me.Name
    End If

    It should allow the form to remain open if the password is correct and close it if it isn't
     
  3. cliffrose

    cliffrose Thread Starter

    Joined:
    Jan 21, 2006
    Messages:
    46
    worked perfectly, thanks.

    is there a way to have the typed letters in the input box come up as *** rather than the actual password being visible?

    E
     
  4. OBP

    OBP

    Joined:
    Mar 8, 2005
    Messages:
    19,895
    Yes you can but it is VERY VERY HEAVY VBA code courtesy of Moviam on the VBAX Forum.
    So do you want to give it a try?
    It might be easier to Disable all of the Fields on the Form and Add the Password as an Unbound Text box on the Form, you can then use an Input Mask set to Password and use simple VBA to enable all the fields if the Password is correct.
    I will have to go soon and we can continue this tomorrow.
     
  5. cliffrose

    cliffrose Thread Starter

    Joined:
    Jan 21, 2006
    Messages:
    46
    I'd love the experience with the heavy code, but the time i have left on this project is minimal......
     
  6. OBP

    OBP

    Joined:
    Mar 8, 2005
    Messages:
    19,895
    You can have the code, but if it proves problematic you would need to contact movian to resolve it.
    See the attached database, you need the Module "Newboxes", which has the heavy Code and the simpler VBA code from the Password Entry Button and the Password Field, which does not need to be Visible, it is only there to show you it working.
     

    Attached Files:

  7. cliffrose

    cliffrose Thread Starter

    Joined:
    Jan 21, 2006
    Messages:
    46
    Thanks- I'll play with it for a bit- but today is my last official day on the project, so i may have to let it go...
     
  8. Sponsor

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Loading...
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/853691

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice