|
-
Mar 9th, 2004, 11:53 AM
#1
Thread Starter
Addicted Member
simple password screen
Hi All,
I have created a simple password scree that validates against 2 fields, User_Name and password. Trouble is it keeps crashing. It appears to begin the login ok and then it all freezes up any ideas appreciated.
Code Below:
Private Sub cmdCheck_Click()
'set up a new recordset
Dim dbPWD As DAO.Database, rsPWD As DAO.Recordset
Dim intResponse As Integer
intResponse = 0
Set dbPWD = CurrentDb
Set rsPWD = dbPWD.OpenRecordset("Select * From tblpwd;", dbOpenDynaset)
'Search and validate
Do While Not rsPWD.EOF
If txtUserName.Value = rsPWD.Fields("User_name") And _
txtPassword.Value = rsPWD.Fields("Password") Then
Form_Startup.Visible = True
Form_pwdAuth.Visible = False
Else
MsgBox ("Invalid Username or password, please try again")
rsPWD.MoveNext
intResponse = intResponse + 1
End If
If intResponse = 3 Then
MsgBox ("You have reached the maximum number of login attempts, please contact an administrator for further assistance.")
'Unload Me
End If
Loop
End Sub
-
Mar 10th, 2004, 11:12 AM
#2
Addicted Member
Hi there,
not sure how far into your routine its getting, if you step into the code it should give you a better idea at what part to look.
Brian
if you fail to plan, you plan to fail
-
Mar 14th, 2004, 03:46 PM
#3
VB Code:
Private Sub cmdCheck_Click()
'NOTE: declaring variables on the same line makes
'each one declared a variant apart from the first one!
Dim dbPWD As DAO.Database
Dim rsPWD As DAO.Recordset
Dim intResponse As Integer
Dim strSQL As String
intResponse = 0
strSQL = "Select * From tblpwd WHERE User_name = '" & _
txtUserName.Value & "' and Password = '" & txtPassword.Value & "'"
Set dbPWD = CurrentDb
Set rsPWD = dbPWD.OpenRecordset(strSQL, dbOpenDynaset)
If Not rsPWD.BOF And rsPWD.EOF Then
Form_Startup.Visible = True
Form_pwdAuth.Visible = False
Else
MsgBox ("Invalid Username or password, please try again")
intResponse = intResponse + 1
End If
If intResponse = 3 Then
MsgBox ("You have reached the maximum number of login attempts," & _
"please contact an administrator for further assistance.")
End If
End Sub
-
Mar 14th, 2004, 03:48 PM
#4
Ah, just one more thing, I think if you're using access and try & reference/call on a field/table column named "password" you might run into problems.
From memory I think this one might be a reserved keyword which access recognises internally so might not realise it being a field name, you might want to rename this to pwd, or passwordtext for example if you run into problems here.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|