Syntax error in SQL Delete statement

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • tara99
    New Member
    • Oct 2006
    • 106

    Syntax error in SQL Delete statement

    strSQL4 = "DELETE * FROM ExecutiveRespon sibilitySecurit y WHERE [ExecutiveRespon sibility]= '" & Me.ExeResponsib ility & "' and [NetworkID] = ' " & Me.UserID & "';"

    DoCmd.RunSQL strSQL4

    I am trying to delete from a table.


    ExecutiveRespon sibility and NetworkID are fields in the table ExecutiveRespon sibilitySecurit y

    Me.ExeResponsib ility and Me.UserID is the name of my combo box and the list box which holds the items thati want to delete.

    can any one tell me what is wrong in this statement
    thanks
  • MMcCarthy
    Recognized Expert MVP
    • Aug 2006
    • 14387

    #2
    strSQL4 = "DELETE * FROM ExecutiveRespon sibilitySecurit y
    WHERE [ExecutiveRespon sibility]= '" & Me.ExeResponsib ility & "'
    and [NetworkID] =" & Me.UserID & ";"

    DoCmd.RunSQL strSQL4
    [/code]

    Assuming NetworkID is a number

    Mary

    Comment

    • tara99
      New Member
      • Oct 2006
      • 106

      #3
      Originally posted by mmccarthy
      strSQL4 = "DELETE * FROM ExecutiveRespon sibilitySecurit y
      WHERE [ExecutiveRespon sibility]= '" & Me.ExeResponsib ility & "'
      and [NetworkID] =" & Me.UserID & ";"

      DoCmd.RunSQL strSQL4
      [/code]

      Assuming NetworkID is a number

      Mary
      No Mary it is string, but don't worry it is solved for the moment.
      It was just the matter or deleting Me and using the variable that i had those two fields stored in.

      Thank you so much for prompt reply

      Comment

      • MMcCarthy
        Recognized Expert MVP
        • Aug 2006
        • 14387

        #4
        Originally posted by tara99
        No Mary it is string, but don't worry it is solved for the moment.
        It was just the matter or deleting Me and using the variable that i had those two fields stored in.

        Thank you so much for prompt reply
        No problem Tara.

        I'm glad you got it sorted. Glad to see you making an effort to answer other posts as well. We'll make an expert out of you yet.

        Merry Christmas


        Mary

        Comment

        Working...