deleteting a record

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • lee123
    Contributor
    • Feb 2007
    • 556

    deleteting a record

    is there a code or away to delete a record from a subform with a button on a form if so how would that be done

    lee123
  • puppydogbuddy
    Recognized Expert Top Contributor
    • May 2007
    • 1923

    #2
    Originally posted by lee123
    is there a code or away to delete a record from a subform with a button on a form if so how would that be done

    lee123
    Lee,
    The basic delete code is shown below, You can add message boxes and confirmations as needed. Be sure you replace the illustrative object names I used with the actual object names from your application.
    Code:
    Private Sub btnDelete_Click()
    
    Dim strSQL As String
    
    strSQL = "Delete * from YourTable where YourField = " & Me.YourSubformControl.Form.textbox & ";"
    
    CurrentDb.Execute strSQL, dbFailOnError
    
    End Sub

    Comment

    Working...