The part of three failed attempts is not working. Please help with this. Thank you!
Please Login or Register to view this content.
The part of three failed attempts is not working. Please help with this. Thank you!
Please Login or Register to view this content.
Without testing, I think its this line:
Try removing the paranetheses. If not, then please explain what the problem is exactly?Please Login or Register to view this content.
abousetta
Please consider:
Thanking those who helped you. Click the star icon in the lower left part of the contributor's post and add Reputation.
Cleaning up when you're done. Mark your thread [SOLVED] if you received your answer.
The problem is that after the 3rd attempt, the message box" "You do not have access to this database. Please contact your system administrator." does not come up.
This might sound like a dumb question, but does it come up after the fourth attempt or does it never come up at all.
Try changing the way the do... loop works:
Please Login or Register to view this content.
abousettaPlease Login or Register to view this content.
P.S. It would help if you could upload a dummy workbook to test on.
I believe you need to remove the Exit Sub from the Else part of the code. It is defeating the purpose of the loop.
Good luck.
I'm going to agree with OnError. Exit sub in your else block is causing you to exit and when you come back into the sub, so your attempt variable is reset to 0. Which kind of makes me think that you need to declare the attempt variable as static. You would also need to initialize that variable on the form load event to 0.
My suggestion,
I'm really leaning at you have a variable scope issue. Each time the user clicks go, the attempts are reset to 0. With static, the number should be saved until the form is closed and is re-initialized.Please Login or Register to view this content.
If you do not exit the sub, there should be no issue with the counter being reset. If you use a static variable, then having got the password wrong three times, you would only get one attempt the next time. Equally, having used the code correctly three times, you would only have one attempt next time - unless you restart the application.
I was assuming that the user was clicking the button again to enter the password that would re-fire the event. Just setting the focus to the textbox wont do anything but point the user to the wrong input. They still have to resubmit the new information somehow. Having it inside a loop esentially doesn't do anything. I can only assume that without exit sub it would hit the 3 attempts quickly because there isn't anything stopping execution when the event fires, while the user enters new data. Unless .setFocus does something I am not aware of for validation. If .setFocus does halt execution then yes. Getting rid of exit sub will work.
To fix the attempts you could reset the static variable to =0 after a sucessful login then you always start fresh after a good login.
I think you are correct - at least that is how it ought to be working. I confess I did not really examine what the original loop was doing - I had input boxes in my mind for some reason. So yes I think you would need something like
Please Login or Register to view this content.
Maybe this will helpPASSWORD FORM6.xls
Hope that helps.
RoyUK
--------
For Excel Tips & Solutions, free examples and tutorials why not check out my web site
Free DataBaseForm example
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks