Hi all
I have the below, when "BtnDeleteAllRecords" is clicked from the main from I want to delete all records in the subform named "SFrmSubDetails", I tried doing a loop with the below code but no success, I have never done loops below so probably completely wrong, wasn't sure what I need to do, unless there is an easier way
FrmMainDetails - Main Form
BtnDeleteAllRecords - Main Form
SFrmSubDetails - Tabular Subform
TxtNameID - Subform AutoNumber
TxtForeNames - Subform Text Box
TxtSurname - Subform Text Box
TxtNameRecordCount - =Count([TxtNameID])
I have the below, when "BtnDeleteAllRecords" is clicked from the main from I want to delete all records in the subform named "SFrmSubDetails", I tried doing a loop with the below code but no success, I have never done loops below so probably completely wrong, wasn't sure what I need to do, unless there is an easier way
FrmMainDetails - Main Form
BtnDeleteAllRecords - Main Form
SFrmSubDetails - Tabular Subform
TxtNameID - Subform AutoNumber
TxtForeNames - Subform Text Box
TxtSurname - Subform Text Box
TxtNameRecordCount - =Count([TxtNameID])
Code:
Private Sub BtnDeleteAllRecords_Click()
[Forms]![FrmMainDetails]![SFrmSubDetails].SetFocus
Do Until [Forms]![FrmMainDetails]![SFrmSubDetails].[Form]![TxtNameRecordCount] = 0
DoCmd.SetWarnings False
DoCmd.RunCommand acCmdDeleteRecord
DoCmd.SetWarnings True
Loop