password ckeck

S

Steve

Hi all,

my question is,

in sheet("data")
I have a list of names in column A and 9 digit numbers in column B

How would i get a userform to check the name and numbers entered in
this page, i have tried Vlookup, but am getting an error message,

any help on the code would be appreciated!

basically i am using a userform with 2 x textbox's

Textbox1 is for username and Textbox2 is for the 9 digit number

i have been able to get the OK button to enable only when 9 digits
have been entered into textbox2 but getting it to check the data in
the sheet("data") is where i have the problem


HYCH


Steve
 
E

excelent

Maby this can give u a hint:

Private Sub TextBox2_AfterUpdate()
On Error GoTo wrongName
x = Sheets("Ark1").Range("A1:A100").Find(TextBox1.Value,
LookIn:=xlValues).Address
If Range(x).Offset(0, 1) = Val(TextBox2.Value) Then
MsgBox ("Ok password"): TextBox1 = "": TextBox2 = ""
Else
MsgBox ("Not Ok password"): TextBox2 = ""
End If
Exit Sub
wrongName:
MsgBox ("Not a valid name")
TextBox1 = "": TextBox2 = ""
End Sub



"Steve" skrev:
 
E

excelent

x = Sheets("Ark1").Range("A1:A100").Find(TextBox1.Value,
LookIn:=xlValues).Address

the 2 lines are just 1 line (format messed up)

"excelent" skrev:
 
S

Steve

x = Sheets("Ark1").Range("A1:A100").Find(TextBox1.Value,
LookIn:=xlValues).Address

the 2 lines are just 1 line (format messed up)

"excelent" skrev:





- Show quoted text -

Many thanks for the tips,

have adjusted as below, but am getting wrong name when i enter a
username and password that are in the list, the list is sorted
alphabetically,

could you review the below code and maybe adjust accordingly. thanks
in advance.

CODE +++++++++++

Private Sub CommandButton1_Click()
Dim iRow As Long

On Error GoTo wrongName
x = Sheets("Data").Range("A1:A100").Find(TextBox1.Value,
LookIn:=xlValues).Address

If Range(x).Offset(0, 1) = Val(TextBox2.Value) Then
With Me
Worksheets("Log").Cells(iRow, "a").Value = .TextBox1.Value
Worksheets("Log").Cells(iRow, "b").Value = Format(Now(), "dd-mm-yy" &
"_" & "hh:mm")
Sheets("Steve").Activate
End With
TextBox1 = "": TextBox2 = ""
Unload Me

Else
MsgBox ("Not Ok password"): TextBox2 = ""
End If

Exit Sub

wrongName:
MsgBox ("Not a valid name")
TextBox1 = "": TextBox2 = ""

End Sub




HYCH
Steve
 
E

excelent

iRow i=0 thats why it go wrong
i have inserted a line to dynamic look for next emty cell in Log

Private Sub CommandButton1_Click()
Dim iRow As Long
iRow = Sheets("Log").Cells(1000, 1).End(xlUp).Row + 1
On Error GoTo wrongName
x = Sheets("Data").Range("A1:A100").Find(TextBox1.Value,
LookIn:=xlValues).Address

If Range(x).Offset(0, 1) = Val(TextBox2.Value) Then
With Me
Worksheets("Log").Cells(iRow, "a").Value = .TextBox1.Value
Worksheets("Log").Cells(iRow, "b").Value = Format(Now(), "dd-mm-yy" & "_" &
"hh:mm")
Sheets("Steve").Activate
End With
TextBox1 = "": TextBox2 = ""
Unload Me

Else
MsgBox ("Not Ok password"): TextBox2 = ""
End If

Exit Sub

wrongName:
MsgBox ("Not a valid name")
TextBox1 = "": TextBox2 = ""

End Sub


"Steve" skrev:
 
S

Steve

iRow i=0 thats why it go wrong
i have inserted a line to dynamic look for next emty cell in Log

Private Sub CommandButton1_Click()
Dim iRow As Long
iRow = Sheets("Log").Cells(1000, 1).End(xlUp).Row + 1
On Error GoTo wrongName
x = Sheets("Data").Range("A1:A100").Find(TextBox1.Value,
LookIn:=xlValues).Address

If Range(x).Offset(0, 1) = Val(TextBox2.Value) Then
With Me
Worksheets("Log").Cells(iRow, "a").Value = .TextBox1.Value
Worksheets("Log").Cells(iRow, "b").Value = Format(Now(), "dd-mm-yy" & "_" &
"hh:mm")
Sheets("Steve").Activate
End With
TextBox1 = "": TextBox2 = ""
Unload Me

Else
MsgBox ("Not Ok password"): TextBox2 = ""
End If

Exit Sub

wrongName:
MsgBox ("Not a valid name")
TextBox1 = "": TextBox2 = ""

End Sub

"Steve" skrev:
















- Show quoted text -

Works a treat many thanks....



Steve
 
S

Steve

welcome

"Steve" skrev:






- Show quoted text -

lol, i know this may sound alittle dozy but just a quick question if i
read the code right, it will allow access if the values in the two
textboxs are equal,? is this right?


i was hoping to have them enter their name and password and then have
these both checked to see if they match the details that are stored in
sheet("Data")

Just tell me if i am wrong,, lol

have a reasonable understanding of simple VBA, but was lost a little
with this one



Steve
 
E

excelent

no thats not right
first it checks if the name is in the range
next it check if the number in same row but column B is eqal to textbox2


"Steve" skrev:
 
S

Steve

no thats not right
first it checks if the name is in the range
next it check if the number in same row but column B is eqal to textbox2

"Steve" skrev:









- Show quoted text -

Sorry Steve, When i ran it just now, i had to enter the name in the
password box to get it to run, otherwise it says wrong password


Steve
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top