Store Values During Calculation

dgaller

Registered User.
Local time
Today, 00:30
Joined
Oct 31, 2007
Messages
60
I am trying to perform a calculation within an IF then Statement. The difference is I need Access to remember a values to complete the calculations prior to setting the final answer. I think this is basic however I am a novice and can't seem to get it to work. Can someone help make this work?

Code:
If [Forms]![Jobentryfrm]![StyleJobCurrentSub]![Assembly] = 39 Then
   BL = ([Forms]![Jobentryfrm]![Height] * 2) + ([Forms]![Jobentryfrm]![Length] * 2) + 8
   bw = [Forms]![Jobentryfrm]![Length] + [Forms]![Jobentryfrm]![Width] + 12
   nl = Bw / 42
   tf = nl * BL / 12
[Forms]![Jobentryfrm]![StyleJobCurrentSub]![TotalDim] = tf * 1.1
   
Else
[Forms]![Jobentryfrm]![StyleJobCurrentSub]![TotalDim] = Round([Forms]![Jobentryfrm]![StyleJobCurrentSub]![ActualDim] + [Forms]![Jobentryfrm]![StyleJobCurrentSub]![Curf], 2)

End If
 
You already appear to be using variables, so what is the issue? "can't seem to get it to work" doesn't give us much to go on. Do you get an error, wrong result, etc?
 
Why doesn't it work the way you have it now?
 
My apologies I don't get the proper result. For example Length =154, width = 40 and height = 52. If I only do.

Code:
'
   bw = [Forms]![Jobentryfrm]![Length] + [Forms]![Jobentryfrm]![Width] + 12
  
[Forms]![Jobentryfrm]![StyleJobCurrentSub]![TotalDim] = bw

I get 15452? Should be 206.
 
It would appear your values are being seen as text/string instead of numbers. You can check what the textboxes are bound to or force the issue with the appropriate conversion function. For integers:

bw = CInt([Forms]![Jobentryfrm]![Length]) + CInt([Forms]![Jobentryfrm]![Width]) + 12
 

Users who are viewing this thread

Back
Top Bottom