Unable to delete a listbox entry using Command button on Access form

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • aanand1
    New Member
    • Jan 2016
    • 1

    Unable to delete a listbox entry using Command button on Access form

    Hi,

    I am unable to delete a selected record on listbox using command button.
    I am new to Access and have made VB code using internet help.
    Here is my code.

    Code:
    Private Sub Delete_Selected_Click()
                Dim SQL11 As String
                DoCmd.SetWarnings False
                SQL11 = " Delete *" & _
                " from dbo_Employee_Project" & _
                " where [dbo_Employee_Project].[Project_ID] ='" & Me.List114.Column(0) & "' AND [dbo_Employee_Project].[Employee_Id] ='" & Me.Text50 & "'"
                MsgBox SQL11
                DoCmd.RunSQL SQL11
                Me.List114.Requery
                 Me.Requery
                DoCmd.SetWarnings True
                
    
    Exit Sub
    
          
    End Sub
    When I click on Command button I get run-time error 3086, Could not delete from specified tables.

    Thanks in advance for your help.

    Anand
    Last edited by Rabbit; Jan 29 '16, 12:42 AM. Reason: Please use [code] and [/code] tags when posting code or formatted data.
  • Seth Schrock
    Recognized Expert Specialist
    • Dec 2010
    • 2965

    #2
    Please post what is in your message box from line 7.

    Comment

    • zmbd
      Recognized Expert Moderator Expert
      • Mar 2012
      • 5501

      #3
      Per Seth, we do need that resolved string.

      Please change the MsgBox on Line7 to:
      Code:
      Debug.Print SQL11
      Run your code
      Open the VBA Editor
      <ctrl><G>

      This will open the immediate window; therein, you should see the resolved SQL11 string.

      Cut and paste that into a post within this thread
      Please format the string using the [CODE/] formatting tool.

      Comment

      Working...