VBA for lookup unit of measure 
Author Message
 VBA for lookup unit of measure

I had tried to program for inventory of restaurant. I has unit conversion
table structure as below:
*UnitCode        kg
 ComposeOf    g
 Factor              1000

And another table is recipe and items had field UnitCode when we buy items
we input quantities as 1 and unitcode is kg, then when sales food the recipe
use items smaller than,for example quantities 100 and unitcode is "g". How
could i know the cost of recipe which i sold. I tried to code by use VBA but
it still not work. Any pointer would be very appreciate.

Thank you in advance.
Suttipong



Sat, 09 Jun 2001 03:00:00 GMT  
 VBA for lookup unit of measure
Suttipong,

This can be done more efficiently by using joins in queries than by using
lookups in code.  Since you haven't described the structures of your other
tables, I'll call the one you've described "tblConversions", and I'll assume
that the other two tables of primary concern are similar to the following:

tblProductPrices
------------------------
ProductID
UnitCode
UnitPrice

tblRecipeIngredients
-----------------------------
RecipeID
ProductID
Quantity
UnitCode

To extract the cost of each ingredient in each recipe, you could use the
following query:

SELECT tblRecipeIngredients.RecipeID, tblRecipeIngredients.ProductID,
tblRecipeIngredients.Quantity, tblProductPrices.UnitPrice *
tblRecipeIngredients.Quantity / tblConversions.Factor AS TotalIngredientCost
FROM (tblProductPrices INNER JOIN tblRecipeIngredients ON
tblProductPrices.ProductID = tblRecipeIngredients.ProductID)
    INNER JOIN tblConversions ON (tblConversions.UnitCode =
tblProductPrices.UnitCode) AND (tblRecipeIngredients.UnitCode =
tblConversions.ComposedOfUnits);

For this to work properly, you must have a record in tblConversions with
every possible ComposedOfUnit.  For example, even if prices by mass are
always for a kilogram, and some recipes use kg as the unit in
tblRecipeIngredients, there must be a record in tblConversions with UnitCode
= "kg", ComposedOfUnits = "kg", and Factor = 1.

HTH,
Nicole


Quote:
>I had tried to program for inventory of restaurant. I has unit conversion
>table structure as below:
>*UnitCode        kg
> ComposeOf    g
> Factor              1000

>And another table is recipe and items had field UnitCode when we buy items
>we input quantities as 1 and unitcode is kg, then when sales food the
recipe
>use items smaller than,for example quantities 100 and unitcode is "g". How
>could i know the cost of recipe which i sold. I tried to code by use VBA
but
>it still not work. Any pointer would be very appreciate.



Sat, 16 Jun 2001 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Printer Unit of Measure

2. D3D9 - Unit of Measure & camera query

3. How to measure 7 dialog box units?

4. Macro to set resource units to Max units

5. VBA disk free space lookup question

6. Excel VBA Userform Lookup

7. Using a lookup value as ControlSource w/o changing the lookup table

8. Trying to do DNS lookup and reverse DNS lookup

9. How to Measure the Success of Purging

10. performance measuring - help

11. Measuring height of table

12. Measure Text

 

 
Powered by phpBB® Forum Software