Reputation: 2625
I have forms as below.
Parent Form : CustomerForm Child Form : OrderForm - in DataSheet view
Each customer can have more orders.
if i select a order and click 'Delete' button, it has to delete. I am not able to get current record and its fields.
No = Me.Form.CurrentRecord
Someone pls help.
Thanks.
Upvotes: 0
Views: 11669
Reputation: 976
No need to store the current record. Use the unique identifier of the selected record in the Subform to select it, then use Docmd.RunSQL. Supposing the button is on your Mainform "Main" and the record in your subform "Sub" with the identifier "id":
Dim sSQL as String sSQL = "DELETE FROM myTable WHERE id = " & Me!Sub!id DoCmd.RunSQL sSQL Me!Sub.Requery
Upvotes: 1