G
GGill
Hi,
I have one table 'tblUsers' with UserNm and Password fields. In my
'frmLogin' form i have 2 text boxes txtUserNm and txtPassword and button
'Login'. So I am trying too on click 'Login' button write code, If string
UserName and Password match from tblUsers then open some new form for example
'frmNew', If not then msg box.
Here is my unfinished code, please make this code work. I think I have to
use rs.Match and rs.NotMatch or Look, but I don't know how, Please help me
finish this code.
----------------------------------
Private Sub cmdLogin_Click()
On Error GoTo Err_cmdLogin_Click
Dim rs as recordset
Set rs = CurrentDB
Dim strUser as string
Dim strPassword as string
txtUserNm.setfocus
strUser=txtUserNm
txtPassword.setfocus
strPassword=txtPassword
If Not IsNull(me.txtUserNm) and Not IsNull(me.txtPassword) Then
set rs = CurrentDB.OpenRecordset("Select * from tbl Users where UserNm = '"
& strUser & " And Password = '" & strPassword &, dbOpenSnapshot)
If rs.EOF Then
Docmd.OpenForm "frmNew"
End If
If Not rs.EOF then
MsgBox "In Correct"
End If
Exit_cmdLogin_Click:
Exit Sub
Err_cmdLogin_Click:
MsgBox Err.Description
Resume Exit_cmdLogin_Click
End Sub
I have one table 'tblUsers' with UserNm and Password fields. In my
'frmLogin' form i have 2 text boxes txtUserNm and txtPassword and button
'Login'. So I am trying too on click 'Login' button write code, If string
UserName and Password match from tblUsers then open some new form for example
'frmNew', If not then msg box.
Here is my unfinished code, please make this code work. I think I have to
use rs.Match and rs.NotMatch or Look, but I don't know how, Please help me
finish this code.
----------------------------------
Private Sub cmdLogin_Click()
On Error GoTo Err_cmdLogin_Click
Dim rs as recordset
Set rs = CurrentDB
Dim strUser as string
Dim strPassword as string
txtUserNm.setfocus
strUser=txtUserNm
txtPassword.setfocus
strPassword=txtPassword
If Not IsNull(me.txtUserNm) and Not IsNull(me.txtPassword) Then
set rs = CurrentDB.OpenRecordset("Select * from tbl Users where UserNm = '"
& strUser & " And Password = '" & strPassword &, dbOpenSnapshot)
If rs.EOF Then
Docmd.OpenForm "frmNew"
End If
If Not rs.EOF then
MsgBox "In Correct"
End If
Exit_cmdLogin_Click:
Exit Sub
Err_cmdLogin_Click:
MsgBox Err.Description
Resume Exit_cmdLogin_Click
End Sub