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 Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

If statement not working

Status
Not open for further replies.

Bullsandbears123

Technical User
Feb 12, 2003
291
US
I am using the below if statement, but it does not seem work. When it processes the statement below it goes to the if else and does NOT process "do this".

Any Ideas?

___________________________________________
dim test1 as string
dim test2 as string

test1="2"
test2=NULL

If test1 <> test2 Then
'do this
else
'do that
endif
 
Dim test1 As Variant
Dim test2 As Variant

test1 = &quot;2&quot;
test2 = Null

If test1 <> test2 Then
'do this
MsgBox (&quot;Here1&quot;)
Else
'do that
MsgBox (&quot;Here2&quot;)
End If

Personally, I do a check for IsNull(FieldName)=True or IsEmpty(FieldName)=True as opposed to using Variant type. htwh

Steve Medvid
&quot;IT Consultant & Web Master&quot;

Chester County, PA Residents
Please Show Your Support...
 
Hi Bullsandbears123,

Glad you're sorted this time, but, for future reference you should note that any expression involving null resolves to null which equates to false in a condition, so the 'else' action is always taken.

Enjoy,
Tony

------------------------------------------------------------------------------------------------------
We want to help you; help us to do it by reading FAQ222-2244 before you ask a question.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top