Update Recordset in MS Access

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • pbala
    New Member
    • Dec 2008
    • 37

    #1

    Update Recordset in MS Access

    Hello,
    I have problem in reset the new password with old one.For that I used the code as
    Code:
    Set rstreset = New ADODB.Recordset
    strtable = "Update USERS SET rstreset!Password = '" & upwd & "' where UserName='" & uname & "'"
    Now I want to update it.How to update this?
    Last edited by NeoPa; Feb 18 '09, 10:43 AM. Reason: Please use the [CODE] tags provided
  • NeoPa
    Recognized Expert Moderator MVP
    • Oct 2006
    • 32669

    #2
    Very confusing question.

    You say you've used this code, yet this isn't workable code. It cannot work.

    Without this to give a clue there is no sense in the question.

    Comment

    • NeoPa
      Recognized Expert Moderator MVP
      • Oct 2006
      • 32669

      #3
      It seems this could work as :
      Code:
      strTable = "Update USERS SET [Password]='" & upwd & "' WHERE [UserName]='" & uname & "'"
      But I still don't understand what your question is. What do you want help with?

      Comment

      • ADezii
        Recognized Expert Expert
        • Apr 2006
        • 8834

        #4
        Originally posted by pbala
        Hello,
        I have problem in reset the new password with old one.For that I used the code as
        Code:
        Set rstreset = New ADODB.Recordset
        strtable = "Update USERS SET rstreset!Password = '" & upwd & "' where UserName='" & uname & "'"
        Now I want to update it.How to update this?
        I'll assume you have a Table named USERS and you wish to Update the Password of a User named uname to upwd. Should that be the case, you can use the following code as a Basic Template:
        Code:
        Dim strSQL As String
        Dim upwd As String
        Dim uname As String
        
        upwd = "New Password"
        uname = "ADezii"
        
        'Does the User even exist?
        If DCount("*", "USERS", "[UserName] = '" & uname & "'") = 0 Then
          MsgBox "The User " & uname & " is not a valid User Name!", vbExclamation, "No User"
            Exit Sub
        End If
        
        strSQL = "Update USERS SET USERS.[Password] = '" & upwd & _
                 "' Where USERS.[UserName] ='" & uname & "'"
        
        CurrentDb.Execute strSQL, dbFailOnError

        Comment

        Working...