Delete Button Question

N

niuginikiwi

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top