Results 1 to 10 of 10
  1. #1
    Delta729 is offline Advanced Beginner
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Nov 2010
    Location
    Los Angeles
    Posts
    95

    update table help


    I have a command button that when clicked changes the value to "In Progress" and adds the current date time to a subform.

    Private Sub cmdStart_Click()
    Me.Status.Value = "In Progress"
    Me.tblTaskTimes_subform!Start = Now()
    End Sub

    This is working fine now, but I also need to change the "Status" on a table tblProjects. I've been trying to get the doCmd Update to work, but I've been unsuccessful since Friday. I'm a complete novice at VBA, can anyone help me out.
    Thanks, even pointing to a good / clear article might help, but I've read several and keep getting it wrong.

    DoCmd.RunSQL "UPDATE tblProjects Set Status=InProgress" WHERE ID = Me.Progrect"

  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,652
    Try


    DoCmd.RunSQL "UPDATE tblProjects Set Status='InProgress' WHERE ID =" Me.Progrect
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    Delta729 is offline Advanced Beginner
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Nov 2010
    Location
    Los Angeles
    Posts
    95
    Thanks for the reply, it's still giving me a compile error.

    Private Sub cmdStart_Click()
    Me.Status.Value = "In Progress"
    Me.tblTaskTimes_subform!Start = Now()
    DoCmd.RunSQL "UPDATE tblProjects Set Status='InProgress' WHERE ID=" Me.Project
    End Sub

  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,652
    On that line? Is Project the name of the control holding the ID?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    Delta729 is offline Advanced Beginner
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Nov 2010
    Location
    Los Angeles
    Posts
    95
    Yes. It's a textbox who's pull in the ID from the tblProject when the form "Task Details" loads and closes the "New Project" form. tblProject is the first table. Each project that is created can have one or more task related to it.

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    Can you post the db here?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  7. #7
    Delta729 is offline Advanced Beginner
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Nov 2010
    Location
    Los Angeles
    Posts
    95
    here is a copy
    Attached Files Attached Files

  8. #8
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    Oh shoot, I forgot the &. Try:

    DoCmd.RunSQL "UPDATE tblProjects Set Status='InProgress' WHERE ID=" & Me.Project
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  9. #9
    Delta729 is offline Advanced Beginner
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Nov 2010
    Location
    Los Angeles
    Posts
    95
    That's great. I'm a little lost though, what does the & do near the end?

  10. #10
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    It concatenates the value from the form into the string.
    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. Update Table after Record Update with Form
    By speciman_A in forum Forms
    Replies: 25
    Last Post: 10-31-2014, 01:00 PM
  2. Replies: 1
    Last Post: 05-17-2013, 12:53 PM
  3. Replies: 7
    Last Post: 09-21-2012, 11:09 AM
  4. Replies: 1
    Last Post: 02-08-2012, 04:50 PM
  5. Replies: 1
    Last Post: 01-22-2011, 12:23 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