M2M relationship management

dasadler
5StarLounger
Posts: 889
Joined: 25 Jan 2010, 16:26
Location: Garden Grove, CA 92844 USA

M2M relationship management

Post by dasadler »

I was reviewing an example DB provided by my friend Slinky from another forum and I understand how it works and have successfully implemented the technique in another DB I am working on. I have found however, that while it is easy to add records... I cannot delete records without getting an error (see below). So is there a way to be able to delete a student or a course from within the form? Maybe select the record on the subform and click a button on the main form that say delete selected student or course?
You do not have the required permissions to view the files attached to this post.
Don

User avatar
HansV
Administrator
Posts: 78391
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: M2M relationship management

Post by HansV »

You can't delete a record from the subform by clearing the combo box, for doing the latter merely sets the value of the combo box to Null, it does not remove the record.
Instead, click the Delete Record button on the toolbar (or ribbon, if you're using Access 2007 or later).
Best wishes,
Hans

dasadler
5StarLounger
Posts: 889
Joined: 25 Jan 2010, 16:26
Location: Garden Grove, CA 92844 USA

Re: M2M relationship management

Post by dasadler »

Thanks Hans. I took your advice and applied it by creating a command button in the subform and assigning Delete to it. Is there any way to prevent the pop up warning about deleting a record and 'Are you sure?"
HansV wrote:You can't delete a record from the subform by clearing the combo box, for doing the latter merely sets the value of the combo box to Null, it does not remove the record.
Instead, click the Delete Record button on the toolbar (or ribbon, if you're using Access 2007 or later).
Don

User avatar
HansV
Administrator
Posts: 78391
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: M2M relationship management

Post by HansV »

You could put code like this in the On Click event procedure of the button:

DoCmd.SetWarnings False
RunCommand acCmdDeleteRecord
DoCmd.SetWarnings True
Best wishes,
Hans

dasadler
5StarLounger
Posts: 889
Joined: 25 Jan 2010, 16:26
Location: Garden Grove, CA 92844 USA

Re: M2M relationship management

Post by dasadler »

Sweet - thank you.
HansV wrote:You could put code like this in the On Click event procedure of the button:

DoCmd.SetWarnings False
RunCommand acCmdDeleteRecord
DoCmd.SetWarnings True
Don