Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 196
  • Last Modified:

If Statement


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"
             Me.Amount1 = CDbl(Me.CalcAmount)
               'CalcAmount=[Percent]*DLookUp("[Amount]","tblLetterOfCredit","[LetterOfCreditID] = " & [Forms]![frmLetterOfCredit_Cont]![LetterOfCreditID])

        End If
End Sub
  • 2
1 Solution
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.
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)
Rey Obrero (Capricorn1)Commented:
sorry this
     If IsNull(Me.Amount1) Or Me.Amount=0 Then

      If IsNull(Me.Amount1) Or Me.Amount1=0 Then
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


Featured Post

Fill in the form and get your FREE NFR key NOW!

Veeam is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now