+ Reply to Thread
Results 1 to 11 of 11

Password protecting UserForm?

  1. #1
    Registered User
    Join Date
    03-13-2008
    Posts
    52

    Password protecting UserForm?

    Please Login or Register  to view this content.
    I am using the above code to password-protect UserForm1 by using UserForm2. Although I know these password protect systems are easily surpassed I need some level of protection in the UserForm as it contains confidential information and it's been requested from a higher level.

    I have highlighted in red where I am encountering the dreaded [91] error "Object variable or With block variable no set".

    Simply put, I have a small range of Usernames and Passwords in range D:E (D being Usernames, E being passwords). I want the password checker to search through the Usernames and passwords and if the relevant Username and Password entered by the user isn't found then I want them to be notified and they have 2 further attempts. After the third attempt the program will simply exit. If they enter a correct Username and Password combination, then they are directed to UserForm1.

    The code above worked like a dream for the counter (which advises the user which try they are on) and for putting a "Logged in as: XXX" message on UserForm1 once successfully entered however only for a singular set Username/Password. Short of giving every one of the expected 300 or so users of this program a copy of their own and changing every bit of code for each user, is there anyway I can edit the above code to make it work?

    Many thanks in advance for any help.

    For your ease of helping, please find a copy of the workbook via the link below - please ignore all the random details in each of the sheets, only the UserForm is important

    http://www.nippyzip.com/uploads/080519105604-01993.zip

    ~Liam
    Last edited by LiamPotter; 05-19-2008 at 10:58 AM.

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    Are those TextBoxes in the UserForm containing the code?
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Registered User
    Join Date
    03-13-2008
    Posts
    52
    Yes they are, please find at the bottom of my post a copy of the program so you can work through yourself. I recommend you put macro's on very high so you can have a look at the code etc.

    ~Liam

  4. #4
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    It doesn't appear to be finding the user name.

    Where did you get this code from?

  5. #5
    Registered User
    Join Date
    03-13-2008
    Posts
    52
    http://www.ozgrid.com/forum/showthre...light=password

    The code in my original post is my edited version to *attempt* to make it work with my UserForm. Do you have any suggestions on what I can do to make it work with my UserForm?

    The code in the link above is for a singular Username and password whereas I want the code to look through the Usernames in my range and the corresponding passwords in the cell to the right (FindR.Offset(0,1)?) from what the user has entered into UserForm2.

    Thank you for taking your time to help me, very much appreciated!

    ~Liam
    Last edited by LiamPotter; 05-19-2008 at 11:45 AM.

  6. #6
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258
    Hello Liam,

    Here is the updated routine. The Find function of a Range objects returns Nothing if the value isn't found in the specified range. A Null String or empty quotes can not be logically compared with a the Nothing object type.
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

  7. #7
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    Try this

    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    03-13-2008
    Posts
    52
    Hi Leith,

    Thank you for your reply. I've pasted your code directly over the top of mine however I'm still encountering a problem. The problem I've now got is an error message 1004: Method 'Range' of object '_Worksheet' failed.

    Any way to overcome this?

    ~Liam

  9. #9
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258
    Hello Liam,

    I forgot to extend your Ranges "D" and "E". Should be...
    Please Login or Register  to view this content.
    There is also an issue with UserForm being displayed. I am working on that now.

    Sincerely,
    Leith Ross

  10. #10
    Registered User
    Join Date
    03-13-2008
    Posts
    52
    Very many thanks for both your help. I've edited the code (using bits and bobs from both of you ) to the following and it works perfectly:

    Please Login or Register  to view this content.
    Again, I can not thank you enough.

    ~Liam

  11. #11
    Registered User
    Join Date
    03-13-2008
    Posts
    52
    Sorry for bumping an old thread but I've just realised that the above code would accept any of the passwords in the range D1:D10 for any of the Usernames whereas I needed it to use the correct password which corresponded to the Username. As such I've got it working with the below code:

    Please Login or Register  to view this content.
    Hope this can be of use to someone!

    ~Liam

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1