Other Topics > Smart Access 1996-2006 > Apr-2003 > Access Answers

Deleting Records,Reports, Data Design

<< Click to Display Table of Contents >>

Navigation:  Other Topics > Smart Access 1996-2006 > Apr-2003 >

Deleting Records,Reports, Data Design

Peter Vogel

Peter Vogel answers a variety of questions centered around deleting records in subforms, setting the RecordSource dynamically in a report, and modeling data. He also gets some help from a reader and tells another to “Just Say No.” I have a master/detail form. I want to have a button on the main form that deletes the current record in the subform. That is, if the user clicks on a record in the subform and then clicks the Delete button on the main form, the record the user selected is deleted.


I don’t have a sample of your database, but one suggestion

that you might want to consider is to put the Delete

button on the subform. I’m concerned that if you put the

Delete button on the main form, the user may think that

clicking the button will delete the master record and its

children, rather than just the currently selected child. One

solution is, of course, to have two Delete buttons (one for

the master record and one for the children), but if you’ve

done that it seems to me that the right place for the Delete

Child button is on the subform.


After that unsolicited advice, let’s look at your

problem. The first thing that you need to do is gain access

to the properties of the form with your detail records. If

you created the subform by dragging a form onto your

main form, Access will have done three things for you:

1. Created a subform control on your main form with

the same name as your subform.

2. Shoved the subform into that control.

3. Set up the subform’s Master/Child properties to keep

the main form and subform synchronized.


So, to get to the subform, you must go to the subform

control that holds it (which has the same name as the

subform) and then use the Form property of the subform

control to gain access to the form. If your subform was

called frmOrders, then the subform control that holds it is

also called frmOrders. To retrieve the subform’s caption,

you’d use:




Read more in the pdf