Solved

if... else don't work?

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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
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…
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…

747 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now