If-Then-Else, VBA statement.

      If condition_1 Then
    [ ElseIf condition_2 Then
           result_2 ]
    [ ElseIf condition_n Then
           result_n ]
      End If

   condition_n      Conditions are evaluated in the order listed.
                    Once a condition is found to be true, the corresponding code
                    will be executed and no further conditions will be evaluated.

   result_n         The code to be executed when a condition is met.

Comparison operators:

Less than <, Less than or equal to <=
Greater than >, Greater than or equal to >=
Not equal <>, Equal =

By default comparisons are case sensitive, to make them case insensitive, use UCase() or LCase()
If ucase(string1) = ucase(string2) then...


Dim intVoltage as Integer
Dim strDescription as String

intVoltage = Me!txtVoltage

 If intVoltage = 110 Then
   strDescription = "US voltage"
 ElseIF intVoltage > 200
   strDescription = "European voltage"
   strDescription = "Other voltage"
 End If

MsgBox strDescription

“You see things; and you say 'Why?' But I dream things that never were; and I say 'why not?'” ~ George Bernard Shaw


Nz - Detect a NULL value or Zero Length string.
IIf - If-Then-Else function (SQL)
Case - If Then Else
For - Loop.

Copyright © 1999-2024 SS64.com
Some rights reserved