Results 1 to 11 of 11
  1. #1
    anwaar is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Aug 2011
    Posts
    18

    Update Multiple Records

    Dear Friends,



    I am using following code to update 1 record in a table named "Evaluators", but this code is updating two records instead of one. It updates my required record and 1st record as well But I want to update only my required record. Kindly guide me.

    Code:
    Private Sub UpdatePassword_Click()
    DoCmd.RunSQL "UPDATE Evaluators SET Evaluators.[Password] = EditPass.value WHERE (((Evaluators.Username)=Username.Value));"
    End Sub

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Try:
    Code:
    Private Sub UpdatePassword_Click()
    DoCmd.RunSQL "UPDATE Evaluators SET Password = '" & Me.EditPass & '" WHERE Username = '" & Me.Username "';"
    End Sub

  3. #3
    ssanfu is offline Master of Nothing
    Windows 2K Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    What type is "EditPass " (text, integer, long)?

    What type is "Username" (text, integer, long)?


    You need to concatenate the values. If EditPass and Username are text, it should look like this:

    Code:
    Private Sub UpdatePassword_Click()
    DoCmd.RunSQL "UPDATE Evaluators SET Evaluators.[Password] = '" & EditPass & " WHERE Evaluators.[Username] = '" & Username & "';"
    End Sub
    Note the delimiters......

  4. #4
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Hmm...isn't that what I just said?

  5. #5
    ssanfu is offline Master of Nothing
    Windows 2K Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Quote Originally Posted by RuralGuy View Post
    Hmm...isn't that what I just said?
    Yep... I was interrupted while trying to post, by that 4 letter word - Work! I hope I did't offend anyone

    So I didn't see your post, since I couldn't/didn't refresh the screen...... I'll be faster next time

  6. #6
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    No problem for me. I was just checking to see if I missed something.

  7. #7
    ssanfu is offline Master of Nothing
    Windows 2K Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Great minds think alike........


    time....

  8. #8
    anwaar is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Aug 2011
    Posts
    18
    Dear ssanfu & RuralGuy,

    I have tried both codes that were suggested by you but encountered with the same error "Syntax error". Kinldy help me.

    (EditPass and Username are the values of two textboxes)

  9. #9
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    Please post the exact code that is getting the error.

  10. #10
    anwaar is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Aug 2011
    Posts
    18
    Probelm solved but in a bit different way

  11. #11
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Do you care to share your solution with others that read this Forum?

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

Similar Threads

  1. Update multiple records at once
    By ariklewis in forum Queries
    Replies: 6
    Last Post: 06-13-2011, 02:33 PM
  2. Update Multiple fields according multiple criterias
    By denis.m in forum Programming
    Replies: 1
    Last Post: 02-21-2011, 11:03 AM
  3. Update dates for multiple (not all) records
    By thekruser in forum Access
    Replies: 2
    Last Post: 08-30-2010, 05:27 PM
  4. Replies: 1
    Last Post: 12-10-2009, 08:41 PM
  5. How to Update 70,000++ Records
    By UCBFireCenter in forum Queries
    Replies: 54
    Last Post: 06-19-2009, 12:43 PM

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