recordset from a query or SQL when gathering data from a null fi

S

salmonella

got a bit of a problem. I need to open a recordset (RS) with restricted data.
One way would be basing the RS on a query however it appears that the WHERE
clause in the query makes it choke becuase if i remove it, it works. How do I
base a RS on a query that has WHERE criteria in it.

The other way I could do it is put the WHERE statement in the source
parameter I use when I open the RS. The problem is that I am gathering data
from fields on a form and don't know how to deal with a situation when they
are null. for example, with a query I would simply say the below and it works
fine, but how do I write the "or is null" part of the below when I open the
RS use VBA? :
((pw_registry.department_name)=forms!memo_board_super!department Or
forms!memo_board_super!department Is Null) And...................
 
S

salmonella

Steve,
thanks for the reply. Can I use ADO (more familar with it)?
I think that I have pretty much done what you suggested and it does not work.
this is what I have:

Dim rs As New ADODB.Recordset
Dim cnn As New ADODB.Connection
Set cnn = Application.CurrentProject.Connection
Dim str As String
str = "select * from mail_send_q"
rs.Open str, cnn, adOpenKeyset, adLockOptimistic

if you strip out the WHERE criteria from "mail_send_Q " it works fine but
with it it crashes.

any idea?????????????
 
S

salmonella

Thanks any way for the help. What you gave me appears to be the same thing I
have tried, but with ADO. There is something about SQL in the query that
(although the query runs by itself), if i try to open a recordset useing it
as the source data it crashes.
anyway, I see if anyone else has an idea

thanks again
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top