Can I simpifly this line of code?

rbinder

rbinder
Local time
Tomorrow, 04:10
Joined
Aug 13, 2005
Messages
25
Greetings,

I was wondering of I can simplify this line of code which to me looks very clumsy. It work but I assume it could be more efficient?

The line is;

If IsNothing(Me.transvalue) Or IsNothing(Me!FrmDestination.Form.sumtransvolume) Or Me.transvalue > Me!FrmDestination.Form.sumtransvolume Or Me.transvalue < Me!FrmDestination.Form.sumtransvolume Then
(obviously it is on one line)

The whole code is
If IsNothing(Me.transvalue) Or IsNothing(Me!FrmDestination.Form.sumtransvolume) Or Me.transvalue > Me!FrmDestination.Form.sumtransvolume Or Me.transvalue < Me!FrmDestination.Form.sumtransvolume Then
MsgBox "There is a volume error " & vbCrLf & _
"the data entry has not been properly completed " & vbCrLf & _
"Please correctly enter or check all Data", vbCritical, gstrAppTitle
Else
etc.


Point two is there a way of simplifying the "<" and ">" to say not equals.

Thanks in advance

rbinder
 
RE;Can I simpifly this line of code?

point 2 not equals is <>
 
Code:
Me.transvalue > Me!FrmDestination.Form.sumtransvolume Or Me.transvalue < Me!FrmDestination.Form.sumtransvolume

I think this is the same thing:

Code:
Not (Me.transvalue = Me!FrmDestination.Form.sumtransvolume)
or you could try
Code:
Me.transvalue <> Me!FrmDestination.Form.sumtransvolume
 
I don't think IsNothing() is a valid function. Maybe you mean IsNull()?
Code:
[COLOR="Green"]'use a With statement to qualify objects[/COLOR]
With Me.FrmDestination.Form
  [COLOR="Green"]'nulls propagate through an expression, so to test for one or more nulls, add the items[/COLOR]
  If Not IsNull(Me.transvalue + .sumtransvolume) Then
[COLOR="Green"]    'and if both are not null, check for inequality[/COLOR]
    If Me.transvalue <> .sumtransvolume Then
[COLOR="Green"]      'some code here[/COLOR]
    End If
  End If
End With
 

Users who are viewing this thread

Back
Top Bottom