lifeson
02-18-2008, 10:29 AM
It has taken me ages to even write down what I am after but here goes:
I have a worksheet with 4 sheets:
1: tblQuoteLine
2: tblPackMat
3: tblPrices
4: QuoteDetail
tblQuoteLine:
This contains a list of entities that have been ordered plus the type and qty of each entity ordered
There are 2 types of entity:
Type 1 is a component
Type 2 is a pack
Column Headers are:
EntityID
EntityTypeID
Qty
tblPackMat:
This contains a list of materials that are contained within a pack
A pack (type 2) can have any number of materials linked to it.
A component (type 1) will not have any materials linked to it.
Column headers are:
PackID
MatID
Qty
tblNWAC:
This contains a list of the prices and descriptions for each of the entities
Column headers are:
EntityID
Description
NWAC (price)
These tables cannot change as they are imported from an external source.
What I am trying to achieve is:
Create a new sheet (QuoteDetail) listing the total quantity and prices of all Materials and components ordered for a quote
So from tblQuoteLine
For each entity:
If the entity is type 1 (a component) then
With sheets(?QuoteDetail?)
Check if the component has already been added then
If not then:
Create a new line with the entityID, lookup the entityDescription and unit price from tblPrice, add the qty from tblQuoteline, calculate a subtotal
If the entity has already been added then:
On the same line where the entity already exists, add the new qty to the existing qty
Recalculate the subtotal cost
If the entity is type 2 (a pack) then
With sheets(?tblPackMat?)
Check if the pack has any materials linked to it
With sheets(?tblQuoteDetail?)
If the entity has materials linked to it, then
Create a new line with the entityID, lookup the entityDescription and unit price from tblPrice, add the qty from tblQuoteline, calculate a subtotal
If the entity has already been added then:
On the same line where the entity already exists, add the new qty to the existing qty
I have a worksheet with 4 sheets:
1: tblQuoteLine
2: tblPackMat
3: tblPrices
4: QuoteDetail
tblQuoteLine:
This contains a list of entities that have been ordered plus the type and qty of each entity ordered
There are 2 types of entity:
Type 1 is a component
Type 2 is a pack
Column Headers are:
EntityID
EntityTypeID
Qty
tblPackMat:
This contains a list of materials that are contained within a pack
A pack (type 2) can have any number of materials linked to it.
A component (type 1) will not have any materials linked to it.
Column headers are:
PackID
MatID
Qty
tblNWAC:
This contains a list of the prices and descriptions for each of the entities
Column headers are:
EntityID
Description
NWAC (price)
These tables cannot change as they are imported from an external source.
What I am trying to achieve is:
Create a new sheet (QuoteDetail) listing the total quantity and prices of all Materials and components ordered for a quote
So from tblQuoteLine
For each entity:
If the entity is type 1 (a component) then
With sheets(?QuoteDetail?)
Check if the component has already been added then
If not then:
Create a new line with the entityID, lookup the entityDescription and unit price from tblPrice, add the qty from tblQuoteline, calculate a subtotal
If the entity has already been added then:
On the same line where the entity already exists, add the new qty to the existing qty
Recalculate the subtotal cost
If the entity is type 2 (a pack) then
With sheets(?tblPackMat?)
Check if the pack has any materials linked to it
With sheets(?tblQuoteDetail?)
If the entity has materials linked to it, then
Create a new line with the entityID, lookup the entityDescription and unit price from tblPrice, add the qty from tblQuoteline, calculate a subtotal
If the entity has already been added then:
On the same line where the entity already exists, add the new qty to the existing qty