help with conditonal expression...please

KIMBOZZZ

Registered User.
Local time
Today, 13:20
Joined
Jun 17, 2002
Messages
14
help with conditonal expression
how do i?......


field a
b
c
d
e
f
g
h
i

i need to make a conditional calculation.... on fields h and i

...h= if g-c= or <0 then h=0
if g-c>0 and <e then h=((g-c)/100)*d
if g-c= or >e then h=(e/100)*d

...i= if g-c<e then i=0
if g-c>e then (((g-c)-e)/100)*f

can anyone form thes two onto the proper syntax for each field? ....pretty please!!!!
 
Looks like a Select Case situation to me ...

Dim xDiff as long (or maybe double if decimal values are poss.)

xDiff = g-c

Select case xDiff
Case Is < = 0
h = 0
Case Is > 0
if xDiff < e then
h = ((g-c)/100)*d
else
h = (e/100)*d
end if
End Select

and similar for the stuff for i

You can get clever with this kind of thing and make the code shorter but that often makes it less obvious how it is working.

HTH

Jeff
 
thanks for the help....
but how do i apply it?
....not very good with code
do i just paste it into the data properties for the field h?
and how do i write for field i?
 
You'll need to place a copy of the code in the After Update event procedures for any of the fields that affect the result of the calculation (so that the result is recalculated if you change any of the fields).

To get at the event procedure ...
Open the form in design view.
Open the property sheet (use the view menu to open this if it is not open).
Click on one of the relevant fields and then find the After Update event property for the field (it will be about halfway down the property sheet if you have the 'All' tab showing).
Click in the After Update row and click on the builder button that appears (it has 3 dots on it).
Select code builder and then type/copy your code.

HTH

Jeff
 

Users who are viewing this thread

Back
Top Bottom