Page 1 of 2 12 LastLast
Results 1 to 15 of 19
  1. #1
    2 Star Lounger
    Join Date
    Sep 2003
    Location
    Toronto, Ontario, Canada
    Posts
    124
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Password hide (2002)

    This may be more of a VB question: I am using an input box to restrict access to a certain tab on a form in MS Access. The code is as follows:

    Private Sub TabCtl0_Change()
    Select Case TabCtl0.Value
    Case 2
    If InputBox("Please enter password", "Protected") = "mypassword" Then
    If MsgBox("Welcome Admin", vbOKOnly, "Verified") = vbOK Then
    End If
    Else
    TabCtl0.Value = 0
    If MsgBox("Password Incorrect", vbOKOnly, "Protected") = vbOK Then
    End If
    End If
    End Select
    End Sub

    I was wondering if its possible to change the input box's style so that any text I enter shows up as a *.

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Password hide (2002)

    You can't do that with an InputBox. Use a text box for the password. Set the Input Mask property of the text box to PASSWORD. You can either place the text box on the form itself, hidden, and make it visible when needed, or create a custom password form with the text box. A separate form is more elegant, but requires more programming.

  3. #3
    Star Lounger
    Join Date
    Aug 2002
    Location
    Wichita, Kansas, USA
    Posts
    71
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Password hide (2002)

    This displays the password as ****** after it is typed in, but I need it to display ****** as the password is typed. Is there a way to do this?

    Thanks,
    Patty

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Password hide (2002)

    If I set the Input Mask property of a text box to PASSWORD, all characters display as *, both while typing them and afterwards.

  5. #5
    Silver Lounger
    Join Date
    Jan 2002
    Posts
    1,615
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Password hide (2002)

    Hi,

    I have a custom form used only for password the way Hans suggested. The textbox's input mask is set as password. I just checked it and it types the *** as it goes and the actual password is never seen. Are you sure you set the imput mask to password?

    Leesha

  6. #6
    Star Lounger
    Join Date
    Aug 2002
    Location
    Wichita, Kansas, USA
    Posts
    71
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Password hide (2002)

    I was using the field in the table that holds the passwords.

    If I am inputting the password into a text box, then do I have to use code to verify the input password to the table containing the actual passwords? I am also using a login name to get to the correct password in the table.

    Thanks!

    Patty

  7. #7
    Silver Lounger
    Join Date
    Jan 2002
    Posts
    1,615
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Password hide (2002)

    Hi Patty,

    I have code similar to yours to verify the password. When I first set it up anyone standing behind me could see what I was typing. I wanted *** the way you indicated. In design mode, if you click on the textbox that you are entering the password into, go to properties, data tab, input mask. Click on the little box next to input mask and select password and follow the prompts. It's the fifth choice down. You can even preview it to see that it is working before finishing. That is how I did mine and its working.

    Good luck,
    Leesha

  8. #8
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Password hide (2002)

    Your users should never enter something directly into a table.

    And yes, you will have to use code to verify the password, for example like this: let's say you have text boxes txtUser and txtPassword. The following code checks if this combination occurs in the table tblUsers, wiith fields User and Password:
    <code>
    If DCount("*", "tblUsers", "User = " & Chr(34) & Me.txtUser & Chr(34) & _
    " And Password = " & Chr(34) & Me.txtPassword & Chr(34)) > 0 Then
    ' Correct combination
    MsgBox "Welcome!", vbInformation
    Else
    ' Incorrect combination
    MsgBox "Impostor!", vbCritical
    End If</code>

  9. #9
    Star Lounger
    Join Date
    Aug 2002
    Location
    Wichita, Kansas, USA
    Posts
    71
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Password hide (2002)

    I'm not sure why I'm having so much trouble following this all the way through. Sorry.

    Do I put the code you showed in the password form - maybe on the Close event? After I get this password form created and do the verify check, do I hook it to the ON OPEN event of the forms and reports I want to use it with?

    Thanks
    Patty

  10. #10
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Password hide (2002)

    I have attached a little demo. It contains one table tblUsers and two forms frmLogin and frmTest.

    frmTest contains a tab control with two tab pages. If you open frmTest by itself, the second tab page is hidden. If you open frmLogin, select a username and provide a password (see the table), then click the button, frmTest will be opened and the second tab page will only be visible if the password corresponded to the username.

    The code is extremely simple: the On Click event of the command button passes True or False to the form in the OpenArgs argument, and the On Load event of the form picks this up to show or hide the second tab page.

    frmLogin code:

    Private Sub cmdLogin_Click()
    Dim blnCorrect As Boolean
    blnCorrect = (DCount("*", "tblUsers", "User = " & Chr(34) & Me.cboUser & Chr(34) & _
    " And Password = " & Chr(34) & Me.txtPassword & Chr(34)) > 0)
    DoCmd.OpenForm FormName:="frmTest", OpenArgs:=blnCorrect
    DoCmd.Close acForm, Me.Name
    End Sub

    frmTest code:

    Private Sub Form_Load()
    Me.Page2.Visible = Nz(OpenArgs, False)
    End Sub

  11. #11
    Star Lounger
    Join Date
    Aug 2002
    Location
    Wichita, Kansas, USA
    Posts
    71
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Password hide (2002)

    I'm not actually just trying to verify the user logging in.

    I am only wanting to pull certain records from the data table into the form, depending on who has logged in. I have to verify their password before I pull the records. So I think I need to do something at the Query level if possible.

    When I've tried hooking the code to the form, it has already pulled the records before it verifies the login. But I haven't played with the latest code you sent so I'll see if I can do anything with it.

    If you have any ideas of what to do at the query level, I'd appreciate it. Maybe I'm going at this from the wrong angle. Sorry I didn't clarify at the beginning that I was using the verification to only pull certain records.

    Thanks for all your input!

    Patty

  12. #12
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Password hide (2002)

    You will have to explain how to distinguish the records that the user is allowed see from those (s)he isn't, based on the password.

  13. #13
    Super Moderator
    Join Date
    Aug 2001
    Location
    Evergreen, CO, USA
    Posts
    6,623
    Thanks
    3
    Thanked 60 Times in 60 Posts

    Re: Password hide (2002)

    Let me chime in here. We often do this kind of thing, and we always use Access User Security and force users to login each time they open the database. That way we can tell who the user is in code when we have to decide whether or not to display restricted information. The CurrentUser() functions works very well in that context. We often put restricted info on a separate tab on the form, and make that tab invisible for any person who should be restricted by simply setting its .Visible property. The method you are using can easily be defeated by someone who knows just a little bit about Access. Hope this is clear and helps - if not post back.
    Wendell

  14. #14
    Star Lounger
    Join Date
    Aug 2002
    Location
    Wichita, Kansas, USA
    Posts
    71
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Password hide (2002)

    I'm following what you are saying about using Access security and being able to compare the current user. You mentioned how to hide data on a tab if they weren't supposed to see that information, but I'm wanting to only show certain records, not certain fields. Also has to work for reports.

    Here is better clarification of what I'm trying to do:
    I have 2 SQL tables - 1 with employee information that includes their supervisor
    1 with the supervisor, supervisor login, and supervisor password
    We are using Windows authentication at the SQL level

    With the Access front-end, when the user tries to open a form or report, it will do the windows authentication and if their windows login isn't valid, they can't see the data.

    When they open the form or report, I only want the supervisor to be able to see their employees. I'm doing this with input parameters in the query to ask for the supervisor login and password. It will then only give the employees related to that supervisor, and only if they entered the correct password.

    But I need the password to not show as they are typing it in - I need the **** at that point.

    I'm looking at all the different information being given and trying to see a new way of doing the above. I'm not there yet, so if you have any more suggestions, they are appreciated.

    I should have explained better at the very beginning. Sorry.

    Thanks for everyone's help!

    Patty

  15. #15
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Password hide (2002)

    If you already have queries that return the records for employees whose supervisor corresponds to the login name, you already have your solution, or so I it seems to me. Just use such queries as record source for your forms and reports.

Page 1 of 2 12 LastLast

Posting Permissions

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