Regina Whipp

The difficult I do immediately, the impossible takes a little bit longer.

Auto-add new child records when adding new record

Forms

Question:

Well, I thought I had finally figured out how to get my form to work the way I want it to.  Meaning, on my form I want the following phone types to display as defaults:

 

Business              (___) ___-____
Busines 2             (___) ___-____
Business Fax       (___) ___-____
Mobile                  (___) ___-____

It doesn’t work.  If I decide to add a new Client/Company I want it to automatically display the default phone types (which I would also like to be able to select the defaults to display).  AND I don’t like subforms.

 

 

Answer:

To do this you would need a combination of a single subform (however, no one will see it) and Allen Browne’s (Microsoft MVP) code.

Allen Browne’s code copies existing child records with its main record to a new record.  You want to copy new child records with or without main record.  To make the code *work for you* your child records are going to need a trigger.

 

The subform has been set-up to *show* five fields.  However, you can adjust your subform to automatically display as many or as few defaults as you like by checking/unchecking the Show check box.  To display your default fields in a specific Order simply fill in a number, leaving it blank will make it random.

As you can see the form above appears as though it is a single form but as you can see, in form design view, that it is actually a form/subform.  However when you add a new record it will automatically add the above fields so the End-User will not have to add the defaults.  This form is locked to show only those five, which the End-User can change should the Client have other phone numbers.

 

This database requires 2002 or above.

Download Auto-Add Defaults 2002-2003 database

Why is that pink?

All my *hidden* fields have a back color of pink.  I started doing that a long time ago so I could keep track of which fields I have hidden in design view.  Fortunately, no one has ever asked me to design a form in that color or I would have to change the color of my *hidden* fields.