Cross checking a total from the parent table to the child table?

  • Thread starter Thread starter Tina Marie
  • Start date Start date
T

Tina Marie

Hi ... I have a main form where a word count field is entered into ... nested
on the main tab of the form is an embedded form that has multiple word counts
.... I want to check if the total word count is equal to the multiple word
counts entered in the nested form? Any suggestions ... ??
 
Private Sub ControlNameOnSubForm_AfterUpdate()
If Me.ControlNameOnSubForm <> Forms!MainFormName!ControlNameOnMainForm Then
MsgBox "The numbers are not the same", vbOKOnly, "You have made a mistake"
End If
End Sub

You could keep it simple and just tell the user they have made a mistake

Don't forget that you can also use something like this to look at the totals
of the user imput to check the figures

You would need to give more details ond control names to a better answer

HtH
 
Hi Wayne ... thanks .. I'll give this a try but if I can't get it ... I can
give you the 'real' object names ... fingers crossed ..
 
Hi Wayne ... the main total word count must equal the addition of all the
subform's word counts ... here's my object names:

Main form: frmRequestForService
main field: intWordCount

Subfrm: sfrmCodes
subfrm field: intCodeWordCount

So ... the intWordCount must equal the sum of all the intCodeWordCounts
....does this make sense ... let me know ... ta
 
Hi Wayne ... the main total word count must equal the addition of all the
subform's word counts ... here's my object names:

Main form: frmRequestForService
main field: intWordCount

Subfrm: sfrmCodes
subfrm field: intCodeWordCount

So ... the intWordCount must equal the sum of all the intCodeWordCounts ...

Something closer to this on the subform’s ‘on exit’ event:

Private Sub sfrmCodes_Exit(Cancel As Integer)
If Me.sum([intCodeWordCount]) <> Forms!frmRequestForService!intWordCount Then
MsgBox "Word Counts are not the same", vbOKOnly, "You have made a mistake"
End If
End Sub

Except ‘sum’ doesn’t work???
 
Hi Tina

I take it you have more than one box holding numbers ??

Your sum would work like you here it (well done for that) but you need to
reference a control on the form. So.... (oh there are other methods but these
seems to be what you're looking for)

Create a new text box and put it in the form's footer (you may have to
select View Form Footer if you can't see it)
Call the new control
txtTotalCodeWordCount

The control source for this will be
=Sum([intCodeWordCount])

Next in the AfterUpdate event of the intCodeWordCount (on the subform) put
you code but change it to something like this

Private Sub sfrmCodes_Exit(Cancel As Integer)
If Me.txtTotalCodeWordCount<> Forms!frmRequestForService!intWordCount Then
MsgBox "Word Counts are not the same", vbOKOnly, "You have made a mistake"
End If
End Sub


Hope this helps a little - let us know if you have problems
 
Hey Wayne..ok will give this one a try ... let you know how it goes ... ta!!
--
Thanks!!

T. Marie


Wayne-I-M said:
Hi Tina

I take it you have more than one box holding numbers ??

Your sum would work like you here it (well done for that) but you need to
reference a control on the form. So.... (oh there are other methods but these
seems to be what you're looking for)

Create a new text box and put it in the form's footer (you may have to
select View Form Footer if you can't see it)
Call the new control
txtTotalCodeWordCount

The control source for this will be
=Sum([intCodeWordCount])

Next in the AfterUpdate event of the intCodeWordCount (on the subform) put
you code but change it to something like this

Private Sub sfrmCodes_Exit(Cancel As Integer)
If Me.txtTotalCodeWordCount<> Forms!frmRequestForService!intWordCount Then
MsgBox "Word Counts are not the same", vbOKOnly, "You have made a mistake"
End If
End Sub


Hope this helps a little - let us know if you have problems





--
Wayne
Trentino, Italia.



Tina Marie said:
Hi Wayne ... the main total word count must equal the addition of all the
subform's word counts ... here's my object names:

Main form: frmRequestForService
main field: intWordCount

Subfrm: sfrmCodes
subfrm field: intCodeWordCount

So ... the intWordCount must equal the sum of all the intCodeWordCounts
...does this make sense ... let me know ... ta
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top