Microsoft Access Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsDatabaseMicrosoft Access Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old January 7th, 2004, 08:31 PM
bakerboy_1111 bakerboy_1111 is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Posts: 14 bakerboy_1111 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Smile Summing and updating table

Hello all,

I have a table at the moment that has the following columns:

Parent_Tag, Child_Tag, Value and Level.

This table represents a tree diagram. The Parent_Tag is the name of the level connected directly above the Child_Tag.

The Child_Tag has an associated Value and Level. The Value is just a number that will be summed, and the Level represents how far down the tree diagram the current Child_Tag is. That is, 0 for top level, 1 for next level etc.

This table has been generated using an append query. Basically, a Child_Tag will have a value only if it is not a Parent_Tag for any other Child_Tag (i.e. if it is at the end of a tree branch). All other Value entries will be Null.

For all these Null values, I would like to add up the Values connected below.

My idea is that I should be able to make an update query that does the following:

- checks to see if a Child_Tag has a Null Value
- Sum the Values for the cases where these Child_Tags are Parent_Tags
- store the summed Value back in the table to replace the Null

As far as I can tell, this will have to be a loop, because the lowest levels will have to be summed before the top ones.

Does anyone know how to design this? Any help will be greatly appreciated.

Cheers,

Bakerboy

PS: I've attached a sample database table to help explain.
Attached Files
File Type: zip sample_table.zip (8.2 KB, 203 views)

Reply With Quote
  #2  
Old January 8th, 2004, 10:57 PM
sbaxter sbaxter is offline
Moderator: Access, SQL
ASP Free God (5000 - 5499 posts)
 
Join Date: Oct 2003
Posts: 5,126 sbaxter User rank is Corporal (100 - 500 Reputation Level)sbaxter User rank is Corporal (100 - 500 Reputation Level)sbaxter User rank is Corporal (100 - 500 Reputation Level)sbaxter User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 4 Days 1 h 2 m 51 sec
Reputation Power: 12
Look at this DB

Run the following queries in this order.

SumValuesWhereTheseChildsAreParents
StoreSumValuesBackToTableToReplaceNulls

If I understood you request, this should be what you want

S-

Reply With Quote
  #3  
Old January 9th, 2004, 01:21 AM
bakerboy_1111 bakerboy_1111 is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Posts: 14 bakerboy_1111 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Smile

Thankyou so much for your reply, I've been working on this for weeks!!

What you've done is almost what I require, but the only problem is that the results aren't exactly correct. But I really appreciate the help nonetheless!!! :-)

For example, SB3 has L9 connected to it, and L9's value is 4. The sum for SB3 is correct at 4. But SB3 connects to SB2. SB2 also has loads L7 and L8 connected to it whose values are 3 and 5 respectively. The total sum for SB2 comes out at 8, when it should be 12 (total should be L7+L8+SB3). I think this is because it's doing the SB2 sum at the same time as the SB3 sum, and is therefore not including the SB3 total.

This was the reason why I thought this may have to be done with a loop of some kind, maybe summing the totals of the highest level first, then progressively down until it reaches level 0 (top level). The only problem is I have no idea how to do this. Do you know how to modify this so that it will include all totals?

Thanks again for your response,

Bakerboy

Reply With Quote
Reply

Viewing: ASP Free ForumsDatabaseMicrosoft Access Help > Summing and updating table


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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 On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway