Solved

Count records in subform

Posted on 2003-11-13
3
406 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
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…

911 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now