Need to calculate Costs only if not empty,dont know how

krayziehustler

New member
Local time
Today, 12:46
Joined
Aug 9, 2007
Messages
7
I have a variable cost that is a calculated field (as in the colum only exists in a query not as a colum in a table) that is variable hours * variable rate....the problem is ppl at my company sometimes dont know how the costs are goign to be broken down so they only put a Variable Cost....

and since they dont know the rate and hours my calculated field returns nothing...

how can i accomplish this, VBA might seem the way to go but i don't know how to use it for Access.....

so basically i need to calcualte the variable cost only if they enter something in var hours and var rate...other wise the var cost should just be what the users type ( so i i guess i have to make Var Costs a column in the table to give users the option of entering it)
 
UPDATE:::

im a programmer and my mind works programmatically here is psuedo code to better undertstand what i need

Code:
if ( [var rate] == 0 AND [var hours]==0) then
   [var costs]=[variable costs] ///the new column i will add thats not a calcualted field
                                           ///like my last one
else
   [var costs]=[var rate] * [var hours]

END IF
 
you could try something like to calculate a field in a query:

iif(isnull([Var Rates]),[variable costs],iif(isnull([Var Hours]),[variable costs],[Var Hours]*[Var Rates]))

this displays whatever is in [variable costs] if either [Var Rates] or [Var Hours] is null, but will calculate the value if both rates and hours are specified.
 
you could try something like to calculate a field in a query:

iif(isnull([Var Rates]),[variable costs],iif(isnull([Var Hours]),[variable costs],[Var Hours]*[Var Rates]))

this displays whatever is in [variable costs] if either [Var Rates] or [Var Hours] is null, but will calculate the value if both rates and hours are specified.

you are the f***ing man!!! thanks it works now, my query is so big i need two of those in there,lol
 
Last edited:

Users who are viewing this thread

Back
Top Bottom