Update Query Not Working

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ahd2008
    New Member
    • Nov 2008
    • 68

    Update Query Not Working

    I have a button to be pressed that should update the employees table, but the

    problme i think is the condition statment "WHERE Employees.Title =" & x



    Can any one fix it, and tell why it didnt work please

    Code:
    Private Sub Toggle25_Click()
    Dim SQL As String
    Dim x  As String
    
    x = "Manager"
    SQL = "UPDATE Employees " & _
    "SET Employees.Title = 'Regional Sales Manager' " & _
    "WHERE Employees.Title =" & x
          
    DoCmd.RunSQL SQL
    End Sub
  • NeoPa
    Recognized Expert Moderator MVP
    • Oct 2006
    • 32662

    #2
    I think simply changing line #8 should do it :
    Code:
    "WHERE Employees.Title = '" & x & "'"
    String literals in SQL need to be surrounded by single-quotes (as your 'Regional Sales Manager' in line #7)

    Comment

    • ahd2008
      New Member
      • Nov 2008
      • 68

      #3
      Many thanks bro & marvelous luck

      Comment

      • NeoPa
        Recognized Expert Moderator MVP
        • Oct 2006
        • 32662

        #4
        No worries. Glad I could help :)

        Welcome to Bytes!

        Comment

        Working...