Solved

if... else don't work?

Posted on 2000-03-07
3
146 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

733 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