Link to home
Start Free TrialLog in
Avatar of pdvsa
pdvsaFlag for United States of America

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]*DLookUp("[Amount]","tblLetterOfCredit","[LetterOfCreditID] = " & [Forms]![frmLetterOfCredit_Cont]![LetterOfCreditID])

        End If
         
End Sub
Avatar of Cluskitt
Cluskitt
Flag of Portugal image

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.
Avatar of Rey Obrero (Capricorn1)
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)
ASKER CERTIFIED SOLUTION
Avatar of Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of pdvsa

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..