Match User Name and Password from Access table

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
 
D

Douglas J. Steele

Already answered in another newsgroup to which you posted the same question.

If you feel you need to post to more than one group (HINT: it's seldom
necessary), please have the courtesy to cross-post (send the one message to
all groups at once), rather than multi-post (send individual messages to
each group). In this way, all responses to your post will be available
together, regardless of what group the responder was in, and the rest of us
won't have to read your post multiple times. (It also uses fewer server
resources)

If you're using Microsoft's web interface to post, you should see an
"Advanced Options" link at the bottom of the page. You can type the names of
the various groups into the Newsgroup box, separating each newsgroup name
with a semicolon.
 
G

GGill

This is first time for me, thank you for the tip. And thank you so much for
the fixing my code.
 

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

Similar Threads

Match UserNm and Password from table 2
Password login code 12
Login form user name and password 6
MsgBox 3
Login Help! 3
Login/Password Question 2
Changing password programatically 2
users set their own password 4

Top