Results 1 to 4 of 4
  1. #1
    rwahdan@gmail.com is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Nov 2015
    Posts
    28

    Exclamation need to test password field

    Hi,



    i have a text field in the table and the form. when the user put the username and password, i want to check both are entered correctly (the username and password are correct). i tried to do that but it seems since the password is showing *** it wont be able to compare it with the word field in the table so i will always get 0 records. how can i test the password field in both the form and table?

    Code:
    Dim dbs As DAO.Database
    Dim rsSQL As DAO.Recordset
    Dim test As Integer
    
    
    username_1.SetFocus
    theusername1 = username_1.Text
    
    
    password_1.SetFocus
    thepassword1 = password_1.Text
    
    
    Set dbs = CurrentDb
    
    
    strSQL = "SELECT username,userpassword FROM users_login where username = '" & theusername1 & "' and userpassword = '" & thepassword1 & "'"
    
    
    Set rsSQL = dbs.OpenRecordset(strSQL)
    
    
    If rsSQL.RecordCount = 1 Then
    
    
    MsgBox "found"
    
    
    Else
    
    
    MsgBox "not found"
    
    
    End If

  2. #2
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 8 Access 2013
    Join Date
    Aug 2013
    Posts
    7,862
    Rather than
    username_1.SetFocus
    theusername1 = username_1.Text

    Set focus somewhere else, other than the username or password textbox controls. If you code executes via a click event of a command button, that will suffice because the command button will have the focus.

    Then, rather than using .Text, use the .Value property of the TextBox Controls.
    dim theusername1 as string
    theusername1 = username_1.Value

  3. #3
    rwahdan@gmail.com is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Nov 2015
    Posts
    28
    thanks a lot, it worked

  4. #4
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 8 Access 2013
    Join Date
    Aug 2013
    Posts
    7,862
    Quote Originally Posted by rwahdan@gmail.com View Post
    thanks a lot, it worked
    Sure thing. Welcome to the forum.
    In VBA, the Text property is what is being typed into the control. The Value property is the result of the AfterUpdate event. After the control is updated/loses focus, the Text property is committed to the Value property. However, when formatting is used, the Text will obey the formatting.

    Thanks for the friends request, but I do not have any friends. Be sure to start a new thread if you have any more questions. There are many members here (including me) willing and able to help.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 4
    Last Post: 03-22-2015, 12:46 AM
  2. Replies: 25
    Last Post: 11-23-2014, 02:43 PM
  3. Test String test besed on table data
    By igourine in forum Programming
    Replies: 3
    Last Post: 12-01-2013, 06:16 AM
  4. Replies: 2
    Last Post: 08-24-2012, 07:28 AM
  5. Keying in Test answers to Access DB from Written Test
    By CityOfKalamazoo in forum Access
    Replies: 3
    Last Post: 03-01-2010, 08:58 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums