Question

I have a form "Client Order" which displays records of "Order Item" in a subform. I need a macro for a button on the Client Order form that deletes Order Item records in that subform when clicked. Access provides DeleteRecord which will delete the record in the form, not the subform records. I only want the subrecords to be deleted, how do I do this?

I have tried using the function:

Function DeletePOSub()
Me.frmSub.Form.Recordset.Delete
Me.frmSub.Form.Recordset.MoveNext
End Function

From the source http://www.access-programmers.co.uk/forums/showthread.php?t=74987

However, this gives me the error "Invalid use of Me keyword" when run.

Was it helpful?

Solution

I use a delete query to accomplish this.

Example:

DoCmd.SetWarnings False 'Turn off warning
DoCmd.OpenQuery "qryDelete" 'Run the delete query
Me.Form.Requery 'Requery the the parent form
DoCmd.SetWarnings True 'Turn warnings on
Me.Form.Painting = True
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top