Solved

Count records in subform

Posted on 2003-11-13
3
408 Views
Last Modified: 2010-05-18
I have a form that contains a textbox called "RejectNum". This form is bound to a table called Reject Main.  I have a subform bound to this form called RejectSub, that is used to enter multiple rejects and their various criteria.  The datasource for the subform is a table called RejectSub, and there is a one to many relationship between the two tables based on a key called UID. (probably useless info, but maybe worth adding).

Each reject has a serial number, and it is entered in a textbox called "SerialNum".  I would like to force a piece of logic to prompt a msgbox when the number of rejects entered on the main form ("RejectNum") does not equal the count of serial numbers entered on the subform.  In other words, if the number in the RejectNum box is 20, users should have to enter 20 serial numbers in the subform, and until they do so, they should not be able to add a record.  Can someone help me with the logic here?

Thanks in advance for your help.  Please let me know if the explanation has been confusing or otherwise inadequate.

IPT
0
Comment
Question by:iptrader
3 Comments
 
LVL 7

Accepted Solution

by:
ala_frosty earned 500 total points
ID: 9776732
I don't think this is the best way to go about getting what you want.

Here's what I would do:

* Delete the field in the RejectMain that has the count of the records in RejectSub. It's redundant.

* in the textbox RejectNum, change the source to
= [sfmRejectSub].form.recordcount

* If you want, before saving the record, prompt the user to verify that s/he there were [sfmRejectSub].form.recordcount Rejects. Users tend to quickly tire of this sort of relentless asking for verification.

* go into the Database Relationships, and set up a cascaded enforced relationship between tblRejectMain and tblRejectSub

The advantage to doing it this way is that in the event of something crashing Access (and who ever heard of that) you have the data you entered in both the Main and the Sub.

There is only so much you can do to prevent the users from making mistakes. Yes, don't make it easy, but the way you were suggesting going about it seems painful to me.
0
 
LVL 39

Expert Comment

by:stevbe
ID: 10025714
No comment has been added lately, so it's time to clean up this TA.
I will leave the following recommendation for this question in the Cleanup topic area:

Accept: ala_frosty {http:#9776732}

Please leave any comments here within the next seven days.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

stevbe
EE Cleanup Volunteer
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

790 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question