Solved

# If Statement

Posted on 2011-10-21
189 Views
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
0
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.
0

LVL 119

Expert Comment

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

LVL 119

Accepted Solution

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

s/b
If IsNull(Me.Amount1) Or Me.Amount1=0 Then
0

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

thanks..
0

## Featured Post

### Suggested Solutions

In the previous article, Using a Critera Form to Filter Records (http://www.experts-exchange.com/A_6069.html), 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 (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — 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…