Less then or greater value is not working

kimpida

Registered User.
Local time
Today, 14:09
Joined
Feb 11, 2014
Messages
15
Code:
---------
If (Me.Variance_From_Budget < 99999 And Me.Variance_From_Budget >= -99999)
---------


This code is working when variance is less then -100,000, but does not work when variance is greater then -100,000.

Please help.:banghead:
 
Not sure if this will change anything, but perhaps your parenthesis need to be rearranged:

Code:
If (Me.Variance_From_Budget < 99999) And (Me.Variance_From_Budget >= -99999)
 
Nope, not working when variance is greater then -100,000.
 
When you say "greater then -100,000", do you mean -101,000 or -99000?
 
Code:
If (Me.Variance_From_Budget < 99999 And Me.Variance_From_Budget >= -99999)

The statement will only be True if Me.Variance_From_Budget is between -99999 and 99998.

Do you want the opposite, i.e. True if Me.Variance_From_Budget is less than -99999 or Greater than 99998?

Code:
If (Me.Variance_From_Budget < -99999) Or (Me.Variance_From_Budget >= 99999)



You could make use of the ABS() function, absolute magnitude, which does away with the +/- and say ...

Code:
If ABS(Me.Variance_From_Budget <= 99999)

Me.Variance_From_Budget between -99999 and +99999

Or

Code:
If ABS(Me.Variance_From_Budget > 99999)

Me.Variance_From_Budget not between -99999 and +99999
 
Last edited:
Code:
---------
If (Me.Variance_From_Budget < 99999 And Me.Variance_From_Budget >= -99999)
---------


This code is working when variance is less then -100,000, but does not work when variance is greater then -100,000.

Please help.:banghead:

So it correctly does not select when <-100,000 and incorrectly does not select for>-100 ,000, in other words it selects nothing?

Brian
 
Here My code:
Code:
'Overbudget projects needs explanation  this one is not working
 
If (Me.Variance_From_Budget < -100000) And (Me.Comments_Explanation_Delta_____100K = "" Or IsNull(Me.Comments_Explanation_Delta_____100K)) Then
        MsgBox "This project is Overbudget, provide explanation why this project is Overbudget.", vbExclamation, "Rules Checker..."
        Me.Comments_Explanation_Delta_____100K.SetFocus
        CheckRules = False
        GoTo Exit_CheckRules
End If
[\code]
 
[code]
'Onbudget project need variance Class - this on works

If (Me.Variance_From_Budget <= 100000 And Me.Variance_From_Budget >= -100000) And (Me.Variance_Class = "" Or IsNull(Me.Variance_Class)) Then
        MsgBox "This project is onbudget project, please add Variance Class 'Onbudget' .", vbExclamation, "Rules Checker ...."
        CheckRules = False
        GoTo Exit_CheckRules
 
[\code]:confused:
 
Code:
If (Me.Variance_From_Budget < 99999 And Me.Variance_From_Budget >= -99999)

The statement will only be True if Me.Variance_From_Budget is between -99999 and 99998.

Do you want the opposite, i.e. True if Me.Variance_From_Budget is less than -99999 or Greater than 99998?

Code:
If (Me.Variance_From_Budget < -99999) Or (Me.Variance_From_Budget >= 99999)



You could make use of the ABS() function, absolute magnitude, which does away with the +/- and say ...

Code:
If ABS(Me.Variance_From_Budget <= 99999)

Me.Variance_From_Budget between -99999 and +99999

Or

Code:
If ABS(Me.Variance_From_Budget > 99999)

Me.Variance_From_Budget not between -99999 and +99999


I am trying to figure out Onbudget and Overbudget variance.

If budget variance is $99,999 thru -$-99,999 project is 'onbudget'

Code:
'Onbudget project need variance Class - this one working 

If (Me.Variance_From_Budget <= 100000 And Me.Variance_From_Budget >= -100000) And (Me.Variance_Class = "" Or IsNull(Me.Variance_Class)) Then
        MsgBox "This project is onbudget project, please add Variance Class 'Onbudget' .", vbExclamation, "Rules Checker ...."
        CheckRules = False
        GoTo Exit_CheckRules
End If
[\CODE]
 
 
If budget variane is $100,000 thru -$100,000 project is 'overbudget' - this one is not working.:banghead:
 
[CODE]
If (Me.Variance_From_Budget < -100000) And (IsNull(Me.Variance_Class) And (IsNull(Me.Comments_Explanation_Delta_____100K))) Then
        MsgBox "This project is Overbudget, Please add Variance Class 'Overbudget'.", vbExclamation, "Rules Checker..."
        CheckRules = False
        GoTo Exit_CheckRules
[\CODE]
 
Please help - thanks
 
If budget variance is $99,999 thru -$-99,999 project is 'onbudget'

If budget variane is $100,000 thru -$100,000 project is 'overbudget' - this one is not working.:banghead:

If it's -100,000 through 100,000 and it's over budget then how can it also be on budget at -999,999 through 999,999? That's a $1 window on either side to get a different result.

I think you mean <= -100,000 OR >= 100,000.
 
If it's -100,000 through 100,000 and it's over budget then how can it also be on budget at -999,999 through 999,999? That's a $1 window on either side to get a different result.

I think you mean <= -100,000 OR >= 100,000.

Yes, you are correct - thanks for correction:D

I mean <= -100,000 OR >= 100,000
 
I hate to mention this but nanscombe asked if this is what you meant back at post 5

Brian
 
So if you want to trap the variance when it is >= (+/-) 100,000 it sounds like the following would do you ...

Code:
If ABS(Me.Variance_From_Budget >= 100000) Then
 
Make allowances for the .01 and .99 between 999,999 and 100,000 if you are using decimals, otherwise, on the rare chance your numbers falls in to that missing dollar.
 
Anything more than, or equal to +/- 100,000
If ABS(Me.Variance_From_Budget >= 100000) Then

Anything more than +/- 99,999
If ABS(Me.Variance_From_Budget > 99999) Then
 
Thanks to all the folks who replied. My problem is resolved.:D
 

Users who are viewing this thread

Back
Top Bottom