vba - Deleting/Adding records on a subform that has a similar record source of the main form -
i trying make subform works splitform.
i use splitform but, far tell, can't filter results of datasheet portion of split form, , not results of rest. see here...
the subformpartdetail returns records orderid equal mainform's orderid. there no filter in mainform returns partdetail records regardless of orderid. in particular instance, main form has 21 records cycle subform has four.
an issue occured when use subform adding or deleting records. when try use main form cycle through records, added ones skipped , deleted ones threw error telling me record attempting go has been deleted. corrected putting these on subform events...
private sub form_afterinsert() dim frm form dim rst recordset set frm = forms!partdetails set rst = frm.recordset rst.requery end sub private sub form_delete(cancel integer) dim frm form dim rst recordset set frm = forms!partdetails set rst = frm.recordset rst.requery end sub
but try delete record mainform displaying subform. code not work , not requery. throws error when cycle away , record.
how can fix this?
i know can move record deleted 1 before deletes using
rst.move
i don't know began testing whether record being deleted same 1 main form displaying.
maybe i'm not understanding situation correctly, there shouldn't need vba achieve this. if subform using link master fields , link child fields subform, ids work automatically. , if have relationship set between 2 tables, if delete order record (and have enforce referential integrity: cascade delete) selected, should clear out line items automatically avoid orphan records.
Comments
Post a Comment