If Statement

Posted on 2011-10-21
Last Modified: 2013-11-27

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
Question by:pdvsa
    LVL 18

    Expert Comment

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

    Expert Comment

    by:Rey Obrero
    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)
    LVL 119

    Accepted Solution

    sorry this
         If IsNull(Me.Amount1) Or Me.Amount=0 Then

          If IsNull(Me.Amount1) Or Me.Amount1=0 Then

    Author Closing Comment

    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

    Do You Know the 4 Main Threat Actor Types?

    Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

    Join & Write a Comment

    In the previous article, Using a Critera Form to Filter Records (, the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
    The first two articles in this short series — Using a Criteria Form to Filter Records ( and Building a Custom Filter ( — discuss in some detail how a form can be…
    In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

    729 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now