How to add two SubTotal in VB

  • Thread starter Balmora via AccessMonster.com
  • Start date
B

Balmora via AccessMonster.com

I'im looking for a way to add two SubTotal in vb here is what i have so fare
and thank you for your intrest

Private Sub Data1_AfterUpdate()
Me.SubTotal1 = Me.Data1 + Me.Data2
End Sub

Private Sub Data2_AfterUpdate()
Me.SubTotal1 = Me.Data1 + Me.Data2
End Sub

Private Sub Data3_AfterUpdate()
Me.SubTotal2 = Me.Data3 + Me.Data4
End Sub

Private Sub Data4_AfterUpdate()
Me.SubTotal2 = Me.Data3 + Me.Data4
End Sub

So Fare all works like it should. Now if i do this with my SubTotal1 and
SubTotal2 It wont add up!

Private Sub SubTotal1_AfterUpdate()
Me.Total = Me.SubTotal1 + Me.SubTotal2
End Sub

Private Sub SubTotal2_AfterUpdate()
Me.Total = Me.SubTotal1 + Me.SubTotal2
End Sub

I have found that if i replace the AfterUpdate of SubTotal1 and 2 by the
Enter event it will add my two SubTotal to give me my total but i need it to
be Automatic for some good reasons ;) and before some one tells me i should
use a query to do this because we should not store this stuff in a table, i
just want to say that i have to, cause its for accounting and want the month
is over well the calculated values should not change

Thank you very much for all of your time hope to see what you can come up
with
Balmora
 
M

mcescher

Add them to the Data subs

Private Sub Data1_AfterUpdate()
Me.SubTotal1 = Me.Data1 + Me.Data2
Me.Total = Me.SubTotal1 + Me.SubTotal2
End Sub
Private Sub Data2_AfterUpdate()
Me.SubTotal1 = Me.Data1 + Me.Data2
Me.Total = Me.SubTotal1 + Me.SubTotal2
End Sub


Good Luck,
Chris M.
 
B

Balmora via AccessMonster.com

Wow thanks for the realy quik responts, i have tryed your sugestion and it
realy works great :)
but i thouhgt i was going to be able to resolve my next problem at the same
time, you see, i have to send the Total to the next record wich is for me the
next month can you see where im going, with the total that i get with your
calculation method, i want to use this

Private Sub Total_AfterUpdate()
If Not IsNull(Me.Total) Then
Data1.DefaultValue = Me.Total
End If
End Sub

It works fine if i use the enter event but i want it to be automatic also
Thanks
 
M

mcescher

Wow thanks for the realy quik responts, i have tryed your sugestion and it
realy works great :)
but i thouhgt i was going to be able to resolve my next problem at the same
time, you see, i have to send the Total to the next record wich is for me the
next month can you see where im going, with the total that i get with your
calculation method, i want to use this

Private Sub Total_AfterUpdate()
 If Not IsNull(Me.Total) Then
     Data1.DefaultValue = Me.Total
 End If
End Sub

It works fine if i use the enter event but i want it to be automatic also
Thanks

Add them to your other field update events


Private Sub Data1_AfterUpdate()
Me.SubTotal1 = Me.Data1 + Me.Data2
Me.Total = Me.SubTotal1 + Me.SubTotal2
If Not IsNull(Me.Total) Then
Data1.DefaultValue = Me.Total
End If
End Sub

ect...

Chris M.
 

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

Top