Print Page | Close Window

FormSubform.mdb (beginner)

Printed From: Roger's Access Library
Category: Roger's Access Library
Forum Name: Roger's Download Samples
Forum Description: A compendium of Microsoft Access 97 and 2000+ routines, each separated into its own sample database.
URL: www.rogersaccesslibrary.com/forum/forum_posts.asp?TID=346
Printed Date: 22 Nov 2019 at 9:38am


Topic: FormSubform.mdb (beginner)
Posted By: Roger Carlson
Subject: FormSubform.mdb (beginner)
Date Posted: 01 Aug 2008 at 4:23am

Please consider donating $1 per sample downloaded, http://www.rogersaccesslibrary.com/whydonations.htm - find out why here .
 

FormSubform.mdb

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")
 
Download
Access 97 (26 KB):
http://www.rogersaccesslibrary.com/forum/uploads/5/FormSubform97.zip - uploads/5/FormSubform97.zip
Access 2000 (40 KB): http://www.rogersaccesslibrary.com/forum/uploads/5/FormSubform2k.zip - uploads/5/FormSubform2k.zip



-------------
Consider donating $1 per sample downloaded, http://www.rogersaccesslibrary.com/whydonations.htm" rel="nofollow - find out why here .<



Print Page | Close Window