emilybartholomew
Technical User
I'm using ADO in some VBA code (access 2000) to run a simple query. Some of the time this query will have no records associated with it. However, this is apparently not ok with VB. It gives me the error "You entered an expression which has no value". I don't care if the resulting recordset is empty. Is there a way to get Access not to care either?
I'm including a little bit of code. It's the first "rs.Open" statement that's causing the problem.
Set rs = New ADODB.Recordset
rs.CursorLocation = adUseServer
rs.Open ("SELECT count(*) FROM Deliverable_players WHERE lead_flag = 0 AND deliverable_id = " & [deliverable_number] & " AND deliverable_year = " & [deliverable_year]), conn
If IsNull(rs(0)) = False Then
rs.Open "SELECT l_name FROM Contacts, Deliverable_players WHERE Contacts.contact_id = Deliverable_players.contact_id AND lead_flag = 0 AND deliverable_id = " & [deliverable_number] & " AND deliverable_year = " & [deliverable_year], conn
num_names = rs.RecordCount
While Not rs.EOF
list = rs(0) & ", " & list
rs.MoveNext
Wend
[dp_list].Value = list
Debug.Print "Should say " & list
End If
I'm including a little bit of code. It's the first "rs.Open" statement that's causing the problem.
Set rs = New ADODB.Recordset
rs.CursorLocation = adUseServer
rs.Open ("SELECT count(*) FROM Deliverable_players WHERE lead_flag = 0 AND deliverable_id = " & [deliverable_number] & " AND deliverable_year = " & [deliverable_year]), conn
If IsNull(rs(0)) = False Then
rs.Open "SELECT l_name FROM Contacts, Deliverable_players WHERE Contacts.contact_id = Deliverable_players.contact_id AND lead_flag = 0 AND deliverable_id = " & [deliverable_number] & " AND deliverable_year = " & [deliverable_year], conn
num_names = rs.RecordCount
While Not rs.EOF
list = rs(0) & ", " & list
rs.MoveNext
Wend
[dp_list].Value = list
Debug.Print "Should say " & list
End If