Results 1 to 3 of 3
  1. #1
    dandoescode is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Dec 2011
    Posts
    85

    Using DoCmd.RunSQL in Forms to write data to table

    Hey, just started dealing with forms, and I'm attempting to write data gathered in a form to a table, seems like it should be pretty simple, but I keep getting an error.



    DoCmd.RunSQL ("UPDATE tblPersonnel SET tblPersonnel.txtPassword =" & newPass & "WHERE tblPersonnel.tblPersonnelID =" & userID & ";")

    The table name is tblPersonnel, I'm attempting to alter txtPassword for a user from their input newPass. The error is 3075, Syntax error (missing operator) in query expression '1WHERE tblPersonnel.tblPersonnelID= 435'

    Note 435 is just the userID value for the particular case

  2. #2
    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,847
    Since txtPassword is a string you need quotes around newPass.

    and you need a space before the "WHERE..."
    Try
    DoCmd.RunSQL ("UPDATE tblPersonnel SET tblPersonnel.txtPassword ='" & newPass & "' WHERE tblPersonnel.tblPersonnelID =" & userID & ";")

  3. #3
    dandoescode is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Dec 2011
    Posts
    85
    Thanks for the speedy response! That fixed it right up.

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

Similar Threads

  1. problem with my DoCmd.RunSQL statement
    By cgclower in forum Access
    Replies: 1
    Last Post: 07-24-2011, 06:12 PM
  2. my first DoCmd.RunSQL
    By broecher in forum Programming
    Replies: 4
    Last Post: 11-05-2010, 09:35 PM
  3. docmd.runsql update
    By Mitch_Aus in forum Programming
    Replies: 2
    Last Post: 10-05-2010, 09:45 AM
  4. Problem with DoCmd.RunSQL
    By Peter01 in forum Programming
    Replies: 2
    Last Post: 09-10-2009, 07:11 PM
  5. docmd.runsql not working
    By Rameez in forum Programming
    Replies: 3
    Last Post: 08-07-2009, 10:07 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