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.
*******
lv_Criteria = "C_Pre_Requisite_T = '115'"
If IsNull(rs_Emps.Fields("E_Area_Specialist"
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.