If Statement Help!

  • Thread starter Thread starter Dave Elliott
  • Start date Start date
D

Dave Elliott

Trying different code to make this work.
If Bidtxt is greater than Text331 then Amount is under message
If '''' ' ''' Less Over
"""""
Right now both messages appear or else it appears when it is not over or
under???


If Me.[Bidtxt].Value > CCur(Me.[Text331].Value) Then
'If ([Bidtxt]) < ([Text331]) Then
MsgBox "Amount is Under Suggested Price"
End If
If Me.[Bidtxt].Value <> CCur(Me.[Text331].Value) Then
'If ([Bidtxt]) > ([Text331]) Then
MsgBox "Amount is Over Suggested Price"
End If
 
Try this:

If Me.[Bidtxt].Value > CCur(Me.[Text331].Value) Then
'If ([Bidtxt]) < ([Text331]) Then
MsgBox "Amount is Under Suggested Price"

ElseIf Me.[Bidtxt].Value <> CCur(Me.[Text331].Value) Then
'If ([Bidtxt]) > ([Text331]) Then
MsgBox "Amount is Over Suggested Price"
End If
 
As written you would see both messages if the value was actually under (The
If > message and the If <> message).
You would see the Over message by itself if the value was over. (If <>
message)
Try one of these structures instead:

If Me.[Bidtxt].Value > CCur(Me.[Text331].Value) Then
MsgBox "Amount is Under Suggested Price"
ElseIf Me.[Bidtxt].Value < CCur(Me.[Text331].Value) Then
MsgBox "Amount is Over Suggested Price"
End If
(If Me.[Bidtxt].Value > CCur(Me.[Text331].Value) there is no message)

Or

Select Case Me.[Bidtxt].Value
Case > CCur(Me.[Text331].Value)
MsgBox "Amount is Under Suggested Price"
Case < CCur(Me.[Text331].Value)
MsgBox "Amount is Under Suggested Price"

Case Else
' Do nothing: Values are equal
End Select

I assume there is a reason you are coercing Me.[Text331].Value to currency
but not Me.[Bidtxt].Value. However, if either of the above don't respond the
way you expect, try coercing Me.[Bidtxt].Value too.
 
This works fine except it still reports over if amounts are the same

If Me.[Bidtxt].Value < CCur(Me.[Text331].Value) Then
MsgBox "Amount is Under Suggested Price"
ElseIf Me.[Bidtxt].Value > CCur(Me.[Text331].Value) Then
MsgBox "Amount is Over Suggested Price"
End If




George Nicholson said:
As written you would see both messages if the value was actually under
(The If > message and the If <> message).
You would see the Over message by itself if the value was over. (If <>
message)
Try one of these structures instead:

If Me.[Bidtxt].Value > CCur(Me.[Text331].Value) Then
MsgBox "Amount is Under Suggested Price"
ElseIf Me.[Bidtxt].Value < CCur(Me.[Text331].Value) Then
MsgBox "Amount is Over Suggested Price"
End If
(If Me.[Bidtxt].Value > CCur(Me.[Text331].Value) there is no message)

Or

Select Case Me.[Bidtxt].Value
Case > CCur(Me.[Text331].Value)
MsgBox "Amount is Under Suggested Price"
Case < CCur(Me.[Text331].Value)
MsgBox "Amount is Under Suggested Price"

Case Else
' Do nothing: Values are equal
End Select

I assume there is a reason you are coercing Me.[Text331].Value to currency
but not Me.[Bidtxt].Value. However, if either of the above don't respond
the way you expect, try coercing Me.[Bidtxt].Value too.
--
George Nicholson

Remove 'Junk' from return address.


Dave Elliott said:
Trying different code to make this work.
If Bidtxt is greater than Text331 then Amount is under message
If '''' ' ''' Less Over """""
Right now both messages appear or else it appears when it is not over or
under???


If Me.[Bidtxt].Value > CCur(Me.[Text331].Value) Then
'If ([Bidtxt]) < ([Text331]) Then
MsgBox "Amount is Under Suggested Price"
End If
If Me.[Bidtxt].Value <> CCur(Me.[Text331].Value) Then
'If ([Bidtxt]) > ([Text331]) Then
MsgBox "Amount is Over Suggested Price"
End If
 
Then I would question if they were really "the same".

--
George Nicholson

Remove 'Junk' from return address.


Dave Elliott said:
This works fine except it still reports over if amounts are the same

If Me.[Bidtxt].Value < CCur(Me.[Text331].Value) Then
MsgBox "Amount is Under Suggested Price"
ElseIf Me.[Bidtxt].Value > CCur(Me.[Text331].Value) Then
MsgBox "Amount is Over Suggested Price"
End If




George Nicholson said:
As written you would see both messages if the value was actually under
(The If > message and the If <> message).
You would see the Over message by itself if the value was over. (If <>
message)
Try one of these structures instead:

If Me.[Bidtxt].Value > CCur(Me.[Text331].Value) Then
MsgBox "Amount is Under Suggested Price"
ElseIf Me.[Bidtxt].Value < CCur(Me.[Text331].Value) Then
MsgBox "Amount is Over Suggested Price"
End If
(If Me.[Bidtxt].Value > CCur(Me.[Text331].Value) there is no message)

Or

Select Case Me.[Bidtxt].Value
Case > CCur(Me.[Text331].Value)
MsgBox "Amount is Under Suggested Price"
Case < CCur(Me.[Text331].Value)
MsgBox "Amount is Under Suggested Price"

Case Else
' Do nothing: Values are equal
End Select

I assume there is a reason you are coercing Me.[Text331].Value to
currency but not Me.[Bidtxt].Value. However, if either of the above don't
respond the way you expect, try coercing Me.[Bidtxt].Value too.
--
George Nicholson

Remove 'Junk' from return address.


Dave Elliott said:
Trying different code to make this work.
If Bidtxt is greater than Text331 then Amount is under message
If '''' ' ''' Less Over """""
Right now both messages appear or else it appears when it is not over or
under???


If Me.[Bidtxt].Value > CCur(Me.[Text331].Value) Then
'If ([Bidtxt]) < ([Text331]) Then
MsgBox "Amount is Under Suggested Price"
End If
If Me.[Bidtxt].Value <> CCur(Me.[Text331].Value) Then
'If ([Bidtxt]) > ([Text331]) Then
MsgBox "Amount is Over Suggested Price"
End If
 
Back
Top