FormSubform.mdb (beginner)

Please consider donating $1 per sample downloaded, find out why here
Access 97 (26 KB)

This form illustrates how to use Domain functions to do a variety of tasks in a Form/Subform situation.

1. DMax is used to obtain the next number for ProductID similar to how the autonumber works. =DMax("ProductID","Product")+1 in the default value of ProductID.

2. DMax is used with the query "qryPartNo" to obtain the next PartID for that particular ProductID. The NZ function converts a null value to zero. This is for the case when there are no part numbers for that product yet. The DMax returns Null, the NZ converts to zero, and then 1 is added to it.

me!PartID =nz(DMax("PartID","qryPartNo"))+1.

This is placed in the BeforeInsert event of the Form. The event also checks to see if the PartID is zero (0) before changing PartID.

3. DFirst is used with the Totals query "qrySumPrice" to find the sum of the Part prices for that ProductID. =DFirst("SumOfPrice","qrySumPrice")




Need Winzip?

Return to Main Page