pdvsa
asked on
If Statement
Experts:
I need and If statement (have attemtpted below)
If Me.Amount1 is Null then display the msgbox
If Me.Amount1 is not null then do the calcualtion.
does it look alright?
I always get the msgbox even if the Me.Amount1 is Not Null.
Private Sub BankID_LostFocus()
If IsNull(Me.Amount1) Then
MsgBox "You should enter in the LC amount above first or else the calculation is not done"
Else
Me.Amount1 = CDbl(Me.CalcAmount)
'CalcAmount=[Percent]*DLoo kUp("[Amou nt]","tblL etterOfCre dit","[Let terOfCredi tID] = " & [Forms]![frmLetterOfCredit _Cont]![Le tterOfCred itID])
End If
End Sub
I need and If statement (have attemtpted below)
If Me.Amount1 is Null then display the msgbox
If Me.Amount1 is not null then do the calcualtion.
does it look alright?
I always get the msgbox even if the Me.Amount1 is Not Null.
Private Sub BankID_LostFocus()
If IsNull(Me.Amount1) Then
MsgBox "You should enter in the LC amount above first or else the calculation is not done"
Else
Me.Amount1 = CDbl(Me.CalcAmount)
'CalcAmount=[Percent]*DLoo
End If
End Sub
It could be a case of scope. Maybe BankID_LostFocus() Me.Amount1 points to a different control, or most likely, to none. Insert a breakpoint in the if line and check the value for Me.Amount1. Alternately, you can simply insert a Debug.Print Me.Amount1 before the if and check the immediate window afterwards.
the syntax is okay, but, is the Amount1 bound to a field with default value of 0 ?
If IsNull(Me.Amount1) Or Me.Amount=0 Then
also, why on this line you are changing the value of Amount1
Me.Amount1 = CDbl(Me.CalcAmount)
If IsNull(Me.Amount1) Or Me.Amount=0 Then
also, why on this line you are changing the value of Amount1
Me.Amount1 = CDbl(Me.CalcAmount)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
that was it.
but I actually should have used:
If IsNull(Me.CalcAmount) Or Me.CalcAmount = 0 Then
i/o If IsNull(Me.Amount1) Or Me.Amount=0 Then
thanks..
but I actually should have used:
If IsNull(Me.CalcAmount) Or Me.CalcAmount = 0 Then
i/o If IsNull(Me.Amount1) Or Me.Amount=0 Then
thanks..