Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

login form

Status
Not open for further replies.

wdu94

Programmer
Aug 15, 2001
61
US
Hello,

I have a access project called PUC. I already create table "PASSWORD".

I want to create user login form. How can do? If you have sample code like that.

Thank you very much for your help.
Jing
 

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

strSQL = "SELECT password FROM tblPassword " & _
"WHERE (UserID = " & _
rsMyRecordset.Fields("UserID") & ") " & _
"AND (password Like '" & password.text & "')"

Set rsMyPassCheck = ConnectionObj.OpenRecordset(strSQL)

if rsMyPassCheck.EOF and rsMyPassCheck.BOF then
msgbox "Password is incorrect. Please try again"
end if
end if

HTH
Alcar
 
Hi, Alcar,

Thanks, Alcar. That's works fine. Do you have ideas for "verify PassWord"? Thanks again.

Jing
 
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 &quot;The User Name must at least be 5 &quot; & _
&quot;characters long. Try Again&quot;

VerifyLogin = False

ElseIf Len(Password) < 5 then

MsgBox &quot;The Password must at least be 5 &quot; & _
&quot;characters long. Try Again&quot;

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 &quot;Numeric and alphabetical &quot; & _
&quot;characters are only allowed. &quot; & _
&quot;Try again.&quot;
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 &quot;Numeric and alphabetical &quot; & _
&quot;characters are only allowed. &quot; & _
&quot;Try again.&quot;
VerifyLogin = False

end if

Next

End Function

Hope this helps,
Alcar
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top