Results 1 to 4 of 4
  1. #1
    kagoodwin13 is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Feb 2012
    Posts
    181

    Update Query in VBA from form combobox value (simple)

    I'm stuck on a rather simple query that doesn't seem to be working.

    I have a form fUpdateProjectStatus, and two fields: cmProjectName (combobox), cmProjectPhase (combobox).

    I am trying to update the table tProject from results on the form.

    Code:
    Private Sub Image14_Click()
    Dim strUpdate As String
    strUpdate = "UPDATE tProject SET tProject.ProjectPhase = "" & Me.[cmProjectPhase].value & "" WHERE (tProject.ProjectName = "" & Me.[cmProjectName].value & "")"
    DoCmd.RunSQL strUpdate
    MsgBox ("Update Successful."), vbOKOnly
    End Sub
    I am getting the Update Successful message, but there is no change in table tProject.



    What am I missing here?

  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
    I think the double quotes are an issue. This should help debug the problem:

    BaldyWeb-Immediate window
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    kagoodwin13 is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Feb 2012
    Posts
    181
    That helped. I had to use some single quotes as well. Thanks!

    Code:
    strUpdate = "UPDATE tProject SET tProject.ProjectPhase = '" & Me.[cmProjectPhase].value & "' WHERE tProject.ProjectName = '" & Me.[cmProjectName].value & "'"

  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!
    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. Simple Update Query
    By sdc1234 in forum Queries
    Replies: 5
    Last Post: 04-16-2014, 02:01 PM
  2. Update in Simple Join Query
    By drunkenneo in forum Queries
    Replies: 3
    Last Post: 11-21-2013, 11:35 AM
  3. Making a simple access combobox and form
    By dukati7 in forum Access
    Replies: 2
    Last Post: 06-15-2012, 01:50 PM
  4. Simple Update Query
    By guygodwin in forum Queries
    Replies: 1
    Last Post: 02-16-2012, 10:59 PM
  5. Replies: 6
    Last Post: 07-28-2011, 04: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