Results 1 to 4 of 4

Thread: simple password screen

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jan 2004
    Location
    North east UK
    Posts
    129

    Question 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

  2. #2
    Addicted Member
    Join Date
    Jan 2002
    Location
    Glasgow, Scotland
    Posts
    202
    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

  3. #3
    Evil Genius alex_read's Avatar
    Join Date
    May 2000
    Location
    Espoo, Finland
    Posts
    5,538
    VB Code:
    1. Private Sub cmdCheck_Click()
    2.     'NOTE: declaring variables on the same line makes
    3.     'each one declared a variant apart from the first one!
    4.     Dim dbPWD As DAO.Database
    5.     Dim rsPWD As DAO.Recordset
    6.     Dim intResponse As Integer
    7.     Dim strSQL As String
    8.    
    9.     intResponse = 0
    10.     strSQL = "Select * From tblpwd WHERE User_name = '" & _
    11.     txtUserName.Value & "' and Password = '" & txtPassword.Value & "'"
    12.    
    13.     Set dbPWD = CurrentDb
    14.     Set rsPWD = dbPWD.OpenRecordset(strSQL, dbOpenDynaset)
    15.    
    16.     If Not rsPWD.BOF And rsPWD.EOF Then
    17.         Form_Startup.Visible = True
    18.         Form_pwdAuth.Visible = False
    19.     Else
    20.         MsgBox ("Invalid Username or password, please try again")
    21.         intResponse = intResponse + 1
    22.     End If
    23.    
    24.     If intResponse = 3 Then
    25.         MsgBox ("You have reached the maximum number of login attempts," & _
    26.         "please contact an administrator for further assistance.")
    27.     End If
    28. End Sub

    Please rate this post if it was useful for you!
    Please try to search before creating a new post,
    Please format code using [ code ][ /code ], and
    Post sample code, error details & problem details

  4. #4
    Evil Genius alex_read's Avatar
    Join Date
    May 2000
    Location
    Espoo, Finland
    Posts
    5,538
    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.

    Please rate this post if it was useful for you!
    Please try to search before creating a new post,
    Please format code using [ code ][ /code ], and
    Post sample code, error details & problem details

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width