Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Counting child records 1

Status
Not open for further replies.
Sep 14, 2010
5
0
0
US
Hello,

I'm trying to open forms based on child records of the parent.

- If no child records exist, open form to add new record
- If only one child record exists, then open form to edit that record.
- If more than one child record exits, open a form to select which record you wish to edit, then open the form to edit that record.

The event to make the choice would be a double-click on the detail portion of the form.

Any thought on best way to achieve this?

Thanks,
Don
 
One method is to use DCount() to check the table for a count of the records with the Primary Key value. If DCount returns zero, open the form to add a new record, if DCount returns 1, open a form with the filter set to the Primary Key, if more than one you can either populate a combobox/listbox with data from each of the records to allow selecting from or use a subform (Continuous) to let them select the record to edit. Once the selection is made, open the edit form using the Primary Key and any other Key fields as the filters for the new form.

PaulF
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top