Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

If then statement in Access

Status
Not open for further replies.

Reggie2004

Technical User
Oct 4, 2004
45
US
Is there a such thing as an If then statement in Access? If so what is the format/

Reg
 
Access" is really VB (but with some of its own custom functions like DoCmd) so the "Access" If ... Then construct is the same as VB
Code:
If <Condition> Then
   ' Do something when <Condition> is TRUE
Else
   ' Do something else when <Condition> is FALSE
End If
There's also the Immediate IF
Code:
IIF ( <Condition>, True Part, False Part )
 
So basically I could just open a query and just insert my code. I am an old programmer from the 80's. I have noticed a lot of similarities. What I want to do on the next half of my project is this...

If final.[SSP] is not null then
final.[filing status] = 3
Else
final.[filing status] = 1
End If
 
That's right ... except that in code you need to use the IsNull function. "IS NOT NULL" is SQL syntax.
Code:
If NOT IsNull(final.[SSP]) Then
   final.[filing status] = 3
Else 
    final.[filing status] = 1
End If
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top