Delete Button Question

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a main form with a subform in DS view. I want a Delete Button on the
main form that deletes selected records on the subform. I got that far with
the code below and works fine for now.

Private Sub btnDeletePlantingDetails_Click()
Dim strSQL As String
Dim vMyID As Variant

vMyID = Me.frmPlantingSubform.Form!txtPDID
strSQL = "DELETE * FROM tblPlantingDetails WHERE ((PlantingDetailsID)=" &
vMyID & ");"
CurrentDb.Execute strSQL, dbFailOnError
Me.frmPlantingSubform.Form.Requery

End Sub

But what I want to do is I got a 2nd subform and I want to use the same
button to delete the selected records.
How do I do that?
I thought of having a button for each subform and enabling/visible=true them
when a record from a respective subform is selected, and I have tried putting
code on the on current event of the subforms but its doing what I intend it
to do...
Can anyone of you folks help me out on this?

Thanks
 
Back
Top