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

Check for empty field

Status
Not open for further replies.

jfrizelle

Programmer
Jan 15, 2004
26
0
0
IE
I want to select records where a particular field is empty. I am using the following code :

*******

lv_Criteria = "C_Pre_Requisite_T = '115'"

If IsNull(rs_Emps.Fields("E_Area_Specialist")) Then
lv_Criteria = lv_Criteria & " AND C_Specialist = ''"
Else
lv_Criteria = lv_Criteria & " AND (C_Specialist = '' OR C_Specialist = 'Lx')"
End If

mySQL = "SELECT C_Id FROM tbl_Courses WHERE " & lv_Criteria
MsgBox mySQL, vbInformation
rs_Courses.Open mySQL, cnn

If Not rs_Courses.EOF Then
.... code if recordset not empty.

**********

However the recordset is always empty, even though there are qualifying records in the database. When the msgbox displays the sql statement it looks fine to me :

SELECT C_Id FROM tbl_Courses WHERE C_Pre_Requisite_T = '115' AND C_Specialist = '' (both text fields)

Any idea what I need to do?

Thanks
Jennie.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top