I am having some confusion about how to ensure I have my application set up normalized and that referential integrity is set right.
I was testing my application and I have a main entry form with sub form on a tab control. For a given subform record, there may be popup forms that allow entry of sub-child records (one to many records for a main form sub-record).
If I try to hit the custom delete button, to delete the sub-form record on the main entry form, I get the messsage "The DoMenuItem action was canceled."
I can figure out that if I go to the pop-up forms and delete those records, then I can go back to the subform and the delete will work.
I saw this thread thread702-1041032 but I want to do something a little different.
If there are child records, I would like to either identify those, or offer to delete them and then the record.
This is my current code:
So the options I am looking at are
A) Trap the DoMenuItem was Canceled message, and say this record has child records that must be deleted first
or
B) Trap that error, say there are sub-records, offer to delete them with a yes/no message and if yes, delete those and then delete the child record
or
C) Should I be setting my referential integrity differently so that the deletes just happen?
I am not sure which way is best to go, or how to accomplish them. Any ideas are appreciated!!!
misscrf
It is never too late to become what you could have been ~ George Eliot
I was testing my application and I have a main entry form with sub form on a tab control. For a given subform record, there may be popup forms that allow entry of sub-child records (one to many records for a main form sub-record).
If I try to hit the custom delete button, to delete the sub-form record on the main entry form, I get the messsage "The DoMenuItem action was canceled."
I can figure out that if I go to the pop-up forms and delete those records, then I can go back to the subform and the delete will work.
I saw this thread thread702-1041032 but I want to do something a little different.
If there are child records, I would like to either identify those, or offer to delete them and then the record.
This is my current code:
Code:
Private Sub cmdDelete_Click()
On Error GoTo Err_cmdDelete_Click
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
Exit_cmdDelete_Click:
Exit Sub
Err_cmdDelete_Click:
MsgBox Err.Description
Resume Exit_cmdDelete_Click
End Sub
So the options I am looking at are
A) Trap the DoMenuItem was Canceled message, and say this record has child records that must be deleted first
or
B) Trap that error, say there are sub-records, offer to delete them with a yes/no message and if yes, delete those and then delete the child record
or
C) Should I be setting my referential integrity differently so that the deletes just happen?
I am not sure which way is best to go, or how to accomplish them. Any ideas are appreciated!!!
misscrf
It is never too late to become what you could have been ~ George Eliot