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
pdvsaProject financeAsked:
Who is Participating?
 
Rey Obrero (Capricorn1)Commented:
sorry this
     If IsNull(Me.Amount1) Or Me.Amount=0 Then

s/b
      If IsNull(Me.Amount1) Or Me.Amount1=0 Then
0
 
CluskittCommented:
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.
0
 
Rey Obrero (Capricorn1)Commented:
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)
0
 
pdvsaProject financeAuthor Commented:
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..
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.