+ Reply to Thread
Results 1 to 17 of 17

protecting userform

  1. #1
    Forum Contributor
    Join Date
    12-09-2006
    Posts
    229

    protecting userform

    is there a way to protect the userform fields or the userform as whole from other people entering date accept the person who has been given the privilege to enter data?


    Thanks

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    You could place code in the userform_initialize event to ask for a password before displaying the form.
    Hope that helps.

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

    Free DataBaseForm example

  3. #3
    Forum Contributor
    Join Date
    12-09-2006
    Posts
    229
    do you know where I can get this code?

  4. #4
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229
    Putting this in the code module for the UserForm should work. The declaration of the module wide variable should be the first thing in the module.
    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    12-09-2006
    Posts
    229
    when I put the code you provided it does not work. I am not sure I put it in the worng place. if I put the wrong password the form is not unloading it pop up again.

    Thanks


    Please Login or Register  to view this content.

  6. #6
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229
    I didn't see the declaration of accessForbidden in your post. I assume it was out of frame when you copied the code from the module.
    But the main problem seemed to be integrating my _Activate routine with yours. I'd try this.
    Please Login or Register  to view this content.

  7. #7
    Forum Contributor
    Join Date
    12-09-2006
    Posts
    229
    Here is the full code just in case I missed up somewhere.

    Thanks
    Attached Files Attached Files

  8. #8
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229
    I'm not sure if this will work right. I'm on a Mac and your ActiveX controls don't work for me. The modifications I made to your UserForm code work, but I'm not sure if the reflected (you getting my copy of the downloaded file) ActiveX controls will work.

    There were two things I modified.
    1) The declaration of accessForbidden as a variable was moved from inside the _Initialize routine to outside all subs. (i.e. declared as a module wide variable)

    2) I put the If...Else...End If structure above into the _Activate routine.

    Also, I noticed that you changed the prompt for password, but not the password.
    Attached Files Attached Files

  9. #9
    Forum Contributor
    Join Date
    12-09-2006
    Posts
    229
    It worked thanks. One more questions is it possible to add more than one password for login?

  10. #10
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229
    Sure.

    Please Login or Register  to view this content.

  11. #11
    Forum Contributor
    Join Date
    12-09-2006
    Posts
    229
    How come when I change the word friend and other password the I get the the password is wrong message? Are these the only password I can use?

    Thanks

  12. #12
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229
    How do you change it? Post the code.

  13. #13
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525
    Please Login or Register  to view this content.

  14. #14
    Forum Contributor
    Join Date
    12-09-2006
    Posts
    229
    it does not work I put BUDDY or buddy or any of the other words still getting the password is wrong and I get the bye message.

    Thanks

  15. #15
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525
    Quote Originally Posted by walid66
    it does not work I put BUDDY or buddy or any of the other words still getting the password is wrong and I get the bye message.

    Thanks
    Hummm
    Please Login or Register  to view this content.
    Or
    Please Login or Register  to view this content.

  16. #16
    Forum Contributor
    Join Date
    12-09-2006
    Posts
    229
    when I put the correct password it works fine but when I put the wrong pass it work the form still pops up it is not hiding. see code below.

    Thanks

    Please Login or Register  to view this content.

  17. #17
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525
    try
    Delete Sub UserForm_Activate() code
    Please Login or Register  to view this content.
    Last edited by jindon; 11-11-2007 at 03:57 AM.

+ 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