Results 1 to 4 of 4
  1. #1
    jpkeller55 is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Sep 2010
    Posts
    169

    Update field in table after update on a subform

    I am sure this is pretty straight forward but having some difficulty here. I am trying to update a field called "LastUpdated" in a table after a subform has been updated. I am using the following code:
    Code:
    DoCmd.RunSQL "UPDATE tblQuestions SET tblQuestions.LastUpdated = Now()
    WHERE tblQuestions.QuestID = QuestID"
    Instead of just upating the one record, I get a message asking me if I want to update all the records in the table (in this case 295). What am I doing wrong?

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Because the value is inside the quotes, each record is being compared to itself. You want something like:

    DoCmd.RunSQL "UPDATE tblQuestions SET tblQuestions.LastUpdated = Now() WHERE tblQuestions.QuestID = " & Me.QuestID

    So the value comes from the form.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    jpkeller55 is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Sep 2010
    Posts
    169
    Thanks Paul...that was it exactly. Works great. Take care.

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Happy to help Jim.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Replies: 3
    Last Post: 10-30-2013, 11:42 AM
  2. update field from one subform to another
    By bluezidane in forum Programming
    Replies: 3
    Last Post: 08-20-2010, 07:54 AM
  3. Replies: 4
    Last Post: 09-03-2009, 02:01 PM
  4. Replies: 1
    Last Post: 03-08-2009, 01:50 PM
  5. how to update only one field in 1 table?
    By viccop in forum Access
    Replies: 3
    Last Post: 02-21-2009, 02:32 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