Solved

if... else don't work?

Posted on 2000-03-07
3
147 Views
Last Modified: 2010-05-02
Is here something wrong:

Do While Data1.Recordset.EOF <> True
  If Data1.Recordset(1).Value = Null Then
    List1.AddItem Data1.Recordset(0)
  Else
    List1.AddItem Data1.Recordset(1)
  End If
   
  Data1.Recordset.MoveNext
Loop

Even if there is NULL in Data1.Recordset(1).Value, List1.AddItem Data1.Recordset(0) never happen?
0
Comment
Question by:majala
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 2

Accepted Solution

by:
damienm earned 50 total points
ID: 2591136
Use

If IsNull(Data1.Recordset(1).Value) then

instead of Data1.Recordset(1).Value = Null
0
 
LVL 4

Expert Comment

by:wesleystewart
ID: 2591782
damienm is correct.  You can't test for null with "= Null" because the right side of the equation will ALWAYS evaluate to False.

Wes
0
 
LVL 14

Expert Comment

by:wsh2
ID: 2592538
Assuming Data1.Recordset(1).Value is a String.. A better way to do this test (and more efficient) is to just test the length of it.. <smile>

If Len(Data1.Recordset(1).Value) > 0 _
Then
  List1.AddItem Data1.Recordset(1)
Else
  List1.AddItem Data1.Recordset(0)
End If
     
 
0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

688 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