A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Subform entry check



 
 
Thread Tools Display Modes
  #1  
Old November 13th, 2009, 12:29 PM posted to microsoft.public.access.forms
hotplate
external usenet poster
 
Posts: 55
Default Subform entry check

Is there any way that I can make sure that the time entries added
together in a subform with a one to many relationship do not exceed a
number in the parent record when added together?

For example, in the parent record I have a field that records the
available time. The subform is used to track how many minutes of that
time is used per each task.

The best validation would be to make sure that all the time entries in
the subform add up to the available time in the parent record, but I
don't know if that is possible.

Any ideas?
  #2  
Old November 13th, 2009, 02:05 PM posted to microsoft.public.access.forms
Tom van Stiphout[_2_]
external usenet poster
 
Posts: 1,653
Default Subform entry check

On Fri, 13 Nov 2009 04:29:30 -0800 (PST), hotplate
wrote:

Yes. In the subform's Form_BeforeUpdate event you can perform the
math, and set Cancel=True if you're unhappy with the result.

To get the total of the subform rows can be done various ways, for
example with a Totals query, with a DSum call, or - my favority - with
a hidden textbox in the subform's footer with its ControlSource set
to:
=Sum(myTextBox)
(of course you replace myObjectNames with yours)
Then you could write:
if Me.mySumTextBox Me.Parent.myTotalTextBox then
msgbox "Aaaarrrccchhh!"
Cancel = True
end if

-Tom.
Microsoft Access MVP



Is there any way that I can make sure that the time entries added
together in a subform with a one to many relationship do not exceed a
number in the parent record when added together?

For example, in the parent record I have a field that records the
available time. The subform is used to track how many minutes of that
time is used per each task.

The best validation would be to make sure that all the time entries in
the subform add up to the available time in the parent record, but I
don't know if that is possible.

Any ideas?

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 05:16 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.