+ Reply to Thread
Results 1 to 6 of 6

Password userform talk to other userforms

  1. #1
    Forum Contributor
    Join Date
    08-22-2011
    Location
    Texas, United States
    MS-Off Ver
    Excel 2007 and 2010
    Posts
    516

    Password userform talk to other userforms

    Hi All,

    I have what i hope to be a pretty simple problem that i just cannot think through.

    I have a userform that allows a user to edit a column of cells. When the user clicks RUN, I have code to check that the userform is correctly filled. Then this:

    Please Login or Register  to view this content.
    This as you can tell is my password userform. On that userform is just a label, text box(which changes the characters to *), okay button, and the X at the top right of the form. Currently i have this code in the password userform:

    Please Login or Register  to view this content.
    It works good to deny my users when they click the run button if they have not entered in the correct password, it also works if they enter in the correct password. If they enter in the correct password, then i continue on with my add userform which edits the column.

    The problem that i am having is that when the user clicks the X at the top right of the password userform it just closes the userform and continues on with the editing of columns, just like the password was correct. Obviously this is not what i want, i would like for when the X is clicked it would unload the userform and Exit Sub in my edit userform so the user cannot edit. I am not sure how to do this. I believe i should be using something in the Password Terminate subroutine, but i am not sure. Any help is greatly appretiated. Thanks.

  2. #2
    Forum Contributor
    Join Date
    08-22-2011
    Location
    Texas, United States
    MS-Off Ver
    Excel 2007 and 2010
    Posts
    516

    Re: Password userform talk to other userforms

    I figured it out for anyone in the future. You will need to set a public variable in the "This Workbook" sheet. This is what i used

    Please Login or Register  to view this content.
    Then on your password terminate event your code would be
    Please Login or Register  to view this content.
    and on every other even in your password in order for a successful entry to work there has to be some place for
    Please Login or Register  to view this content.
    Then on every userform that calls the password userform you need to put this code
    Please Login or Register  to view this content.
    Regards,
    amotto

    If I helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)

  3. #3
    Forum Expert
    Join Date
    02-14-2009
    Location
    .
    MS-Off Ver
    ................
    Posts
    2,840

    Re: Password userform talk to other userforms

    Somethng simpler.. Use the CloseMode parameter of the UserForm_QueryUnloadf event handler...
    Please Login or Register  to view this content.
    The CloseMode is 0 if the red Close button in the title is cancelled, 1 if being unloaded in code and 2 (I think) if Windows is closing. Set the Cancel parameter to True to cancel the close.

  4. #4
    Forum Contributor
    Join Date
    08-22-2011
    Location
    Texas, United States
    MS-Off Ver
    Excel 2007 and 2010
    Posts
    516

    Re: Password userform talk to other userforms

    Cytop,

    That did not work how i was wanting, it still doesn't close my password userform, it just poped up a message that says "Close Canceled". I want them to be able to close the password userform, just if they do then don't run the edit code. My solution did not work as planned so i am opening the post up again.

    Can you build on your sub to make it work for me?

    Thanks

  5. #5
    Forum Contributor
    Join Date
    08-22-2011
    Location
    Texas, United States
    MS-Off Ver
    Excel 2007 and 2010
    Posts
    516

    Re: Password userform talk to other userforms

    I thought that creating a public variable would work, but i have never created one before so i was unsure of where to define if, so i did it in ThisWorkbook. which is not working for me. do i need to define it above each of my userforms, or what?
    Last edited by amotto11; 03-21-2013 at 12:12 PM.

  6. #6
    Forum Contributor
    Join Date
    08-22-2011
    Location
    Texas, United States
    MS-Off Ver
    Excel 2007 and 2010
    Posts
    516

    Re: Password userform talk to other userforms

    I think i figured it out. I used my solution and instead of using a public variable in the ThisWorkbook, i used a global variable in a new blank module, and i didn't unload the password userform after i set Exiting, i hid the password userform instead. I believe this should work for me, but if you have a simpler solution, because i have to do an if statement on all of my userform going my route, i would be glad to heat it. Thanks for all the help

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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