S
salmonella
Did not get an solution so I am reposting the problem. I am having trouble
opening a ADO recordset using a select query as the data source. It works
fine IF there is no where clause in the query however, the query with the
select clause works fine if ran by itself.
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.
Does any one know what I may be doing wrong?
Also, I suppose another way to solve the problem would be to dump the query
and just add the SQL stuff to the connection string. I am referencing user
data in a form’s fields so I need to account for a null value. When I do it
in a query it looks like:
((pw_registry.department_name)=forms!memo_board_super!department Or
forms!memo_board_super!department Is Null) And (then next criteria, and so on)
How to I write the ‘or is null’ part in the connection string in VBA? For
example str = "select * from pw_registry where department_name = " &
forms!memo_board_super!department & “ OR …………………. (then what?)
thanks
opening a ADO recordset using a select query as the data source. It works
fine IF there is no where clause in the query however, the query with the
select clause works fine if ran by itself.
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.
Does any one know what I may be doing wrong?
Also, I suppose another way to solve the problem would be to dump the query
and just add the SQL stuff to the connection string. I am referencing user
data in a form’s fields so I need to account for a null value. When I do it
in a query it looks like:
((pw_registry.department_name)=forms!memo_board_super!department Or
forms!memo_board_super!department Is Null) And (then next criteria, and so on)
How to I write the ‘or is null’ part in the connection string in VBA? For
example str = "select * from pw_registry where department_name = " &
forms!memo_board_super!department & “ OR …………………. (then what?)
thanks