B
BenL712
Hello all. I've been trying to execute a query from code and cannot get it
to work. I have read through the various posts on this subject and have
tried everything I could find (use ' instead of ", generate a text string of
the query that evaluates the parameters and pass that to DAO, use chr() to
make ' and ", etc.) but nothing seems to work. I have commented out the
OpenRecordset command to debug the actual query string, and it appears to be
okay - both parameters are being populated. But it still keeps coming back
with too few parameters. Below is a copy of the code:
Dim rst As DAO.Recordset
Dim db As DAO.database
Dim strQuery As String
strQuery = "SELECT tblEmployees.EmailAddress " & _
"FROM (tblEmployees INNER JOIN tblProjectSupport ON " & _
"tblEmployees.EmployeeID = tblProjectSupport.EmployeeID) " & _
"INNER JOIN tblDefFunction ON tblProjectSupport.FunctionID =
" & _
"tblDefFunction.FunctionID " & _
"WHERE tblProjectSupport.ProjectID = " & _
[Forms]![frmProjectSupport].[FilterProjectID] & _
" And tblDefFunction.FunctionDesc = " & _
"'" & [Forms]![frmProjectSupport].[EmailFunctionDesc] & "*'"
& _
"GROUP BY tblEmployees.EmailAddress " & _
"HAVING tblEmployees.EMailAddress Is Not Null " & _
"ORDER BY tblEmployees.EmailAddress;"
Set db = CurrentDb()
Set rst = db.OpenRecordset(strQuery)
..
..
..
Any thoughts?
to work. I have read through the various posts on this subject and have
tried everything I could find (use ' instead of ", generate a text string of
the query that evaluates the parameters and pass that to DAO, use chr() to
make ' and ", etc.) but nothing seems to work. I have commented out the
OpenRecordset command to debug the actual query string, and it appears to be
okay - both parameters are being populated. But it still keeps coming back
with too few parameters. Below is a copy of the code:
Dim rst As DAO.Recordset
Dim db As DAO.database
Dim strQuery As String
strQuery = "SELECT tblEmployees.EmailAddress " & _
"FROM (tblEmployees INNER JOIN tblProjectSupport ON " & _
"tblEmployees.EmployeeID = tblProjectSupport.EmployeeID) " & _
"INNER JOIN tblDefFunction ON tblProjectSupport.FunctionID =
" & _
"tblDefFunction.FunctionID " & _
"WHERE tblProjectSupport.ProjectID = " & _
[Forms]![frmProjectSupport].[FilterProjectID] & _
" And tblDefFunction.FunctionDesc = " & _
"'" & [Forms]![frmProjectSupport].[EmailFunctionDesc] & "*'"
& _
"GROUP BY tblEmployees.EmailAddress " & _
"HAVING tblEmployees.EMailAddress Is Not Null " & _
"ORDER BY tblEmployees.EmailAddress;"
Set db = CurrentDb()
Set rst = db.OpenRecordset(strQuery)
..
..
..
Any thoughts?