just put two textboxes on the form and one command button.
the firstone is the username textbox, the secend one is the password texbox.
Remember to go to the property of the second textbox and choose the data tab, then select the input mask porperty and type password in it.
This why the password will show as *s
on the event of the commandbutton:
strSQL = "SELECT UserName, UserID FROM tblUsers " & _
"WHERE UserName Like '" & username.text & "'"
Set rsMyRecordset = connectionObj.OpenRecordset(strSQL)
if rsMyRecordset.EOF AND rsMyRecordSet.BOF then
MsgBox "Username is incorrect. Please try again"
Else
well you are already verifying it through the database, but if you need more control like what type of characthers are typed and the minimum lenght of the password, then inster this function that you will call before accessing the DB:
in a module it would be public function...
Private Function VerifyLogin(UserName as String, Password as String) as Boolean
If Len(UserName) < 5 then
MsgBox "The User Name must at least be 5 " & _
"characters long. Try Again"
VerifyLogin = False
ElseIf Len(Password) < 5 then
MsgBox "The Password must at least be 5 " & _
"characters long. Try Again"
VerifyLogin = False
Else
VerifyLogin = True
End If
For i = 1 to Len(UserName)
if (ASC(Mid(UserName,i,1)) > 48 AND _
ASC(Mid(UserName,i,1)) < 57) OR _
(ASC(Mid(UserName,i,1)) > 65 AND _
ASC(Mid(UserName,i,1)) < 90) OR _
(ASC(Mid(UserName,i,1)) > 97 AND _
ASC(Mid(UserName,i,1)) < 122) then
VerifyLogin = True
else
MsgBox "Numeric and alphabetical " & _
"characters are only allowed. " & _
"Try again."
VerifyLogin = False
end if
Next
For i = 1 to Len(Password)
if (ASC(Mid(Password,i,1)) > 48 AND _
ASC(Mid(Password,i,1)) < 57) OR _
(ASC(Mid(Password,i,1)) > 65 AND _
ASC(Mid(Password,i,1)) < 90) OR _
(ASC(Mid(Password,i,1)) > 97 AND _
ASC(Mid(Password,i,1)) < 122) then
VerifyLogin = True
else
MsgBox "Numeric and alphabetical " & _
"characters are only allowed. " & _
"Try again."
VerifyLogin = False
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.