Password Form with User box.Login_P

Houdinii

New Member
Joined
Aug 12, 2012
Messages
13
I have created a UserForm named Login_Pad with 2 UserBox's and 2 CommandButton's
The First UserBox user labeled "User" the second UserBox is labeled "Password".
The First CommandButton is labeled "OK" the second CommandButton is labeled "Cancel"

The idea here is to show this UserForm using "Login_Pad.Show" then have the user enter their User ID and password and press the CommandButton "OK".

At this point I want to search their user name on a worksheet called "Setup" cell's B3:B50 at that point confirm that the password entered equals the password in the adjacent cell C3:C50.

If these compare exit out of Login_Pad and allow the original script to continue.
If these do not compare exit out of Login_Pad and goto lastline of original script

I have tried different ways to accomplish this, the last way I thought of was to write the contents of the UserForm" onto the sheet "Setup" then do a basic compare their using the "=" sign. Unfortunatly I have been unsuccessful at getting the data to the spread sheet.


The Following is the script file from the UserForm Login_Pad.
-----------------------------------------------------------------------
Private Sub Canceled_Click()
Dim MyPassword
MyPassword = "Canceled"
Login_Pad.Hide


End Sub
--------------------------------
Private Sub OK_Click()
'Theese command lines did not check to see if password is correct.
' Dim MyPassword
' MyPassword = "Aproved"




Login_Pad.Hide


End Sub
---------------------------------
Private Sub User_Box_Change()
' Dim User
' User = "Aproved"


End Sub
----------------------------------
Private Sub Password_Box_Change()
' UserPassword = "Aproved"


End Sub
-----------------------------------
Private Sub UserForm_Click()
'Theese commands did not work here
'Sheets("Setup").Range("D33").Value = User.Text
'Sheets("Setup").Range("E33").Value = Password.Text


End Sub
-----------------------------------
Private Sub User_AfterUpdate()
'This commands did not work here
Sheets("Setup").Range("D33").Value = User.Text
End Sub
-----------------------------------
Private Sub Password_AfterUpdate()
'This commands did not work here
Sheets("Setup").Range("E33").Value = Password.Text
End Sub



I am somewhat of a novice on Excell but have some basic knowledge. Thank you all in advance for your thoughts and ideas.
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
put the code to the OK button of your userform and adjust if required

Code:
Private Sub CommandButton1_Click()
Dim username As String
Dim password As String

username = Me.TextBox1.Value
password = Me.TextBox2.Value

For Each ThisCell In Sheets("Setup").Range("B3:B50")
If UCase(ThisCell.Value) = UCase(username) And UCase(ThisCell.Offset(, 1).Value) = UCase(password) Then
MsgBox "Access Granted"
Exit Sub
End If
Next ThisCell
MsgBox "Access Denied"
End Sub
 
Last edited:
Upvote 0
From what I am seeing this script would simply tell the user that access was granted or not, Once the Sub for the "OK" button has finished execution it would release back to user form and not close the user form or provide away for the original script that called for this password check to know the answer. Howeve I must thank you for your hard work on this script, Please let me know if I am missing something maybe it is right in front of my face and I am not getting it.
 
Upvote 0
Welcome to the Board!

If you PM me your e -mail address I'll send you a workbook that does what you want. It's been floating around here for years after several of us put one together since it's such a recurring topic.
 
Upvote 0
It's been floating around here for years after several of us put one together since it's such a recurring topic.

Would it be easier to have a thread that links to the workbook so people can download it? That would save you emailing it to each person who would like it as you could post a link in your reply.
 
Upvote 0
Welcome to the Board!

Would it be easier to have a thread that links to the workbook so people can download it? That would save you emailing it to each person who would like it as you could post a link in your reply.

That's a good idea. I'll have to check with the site admins to see if we can do it, if not I can post it to my SkyDrive account. Fair warning though, we put it together in Excel 2000, so it's in dire need of a facelift. If you'd like a shot at it I'll be happy to send you a copy as well.
 
Upvote 0
I'm looking for pretty much exactly what Tatts was after. I've sent a PM to Smitty - I hope that's ok.
 
Upvote 0

Forum statistics

Threads
1,223,214
Messages
6,170,771
Members
452,353
Latest member
strainu

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top