You have to call your SQL statement from a string and open a recordset.<br>
<br>
Here is a piece of code where I ran a SQL query and returned the number of resulting records. Of course, you will have to substitute your own SQL and you can use a continuation character at the end of lines instead of concatenating strings....<br>
<br>
Sub Chart9_Issued()<br>
<br>
Dim rstChart9_Issued As Recordset<br>
<br>
Set dbs = CurrentDb<br>
<br>
strSQL = "SELECT qryExportView.I_PROBLEM_NO, "<br>
strSQL = strSQL + "qryExportView.RSE_ID, qryExportView.ISSUE_DATE "<br>
strSQL = strSQL + "FROM qryExportView "<br>
strSQL = strSQL + "WHERE (((qryExportView.RSE_ID)<> ""ERROR2""

"<br>
strSQL = strSQL + "AND ((qryExportView.ISSUE_DATE)>= #" + strBegin + "# "<br>
strSQL = strSQL + "AND (qryExportView.ISSUE_DATE) < #" + strEnd + "#"<br>
strSQL = strSQL + "

);"<br>
<br>
Set rstChart9_Issued = dbs.OpenRecordset(strSQL)<br>
<br>
With rstChart9_Issued<br>
If .BOF = False Then<br>
.MoveLast<br>
lngChart9_Issued = rstChart9_Issued.RecordCount<br>
Else: lngChart9_Issued = 0<br>
End If<br>
<br>
'Debug.Print lngChart9_Issued<br>
rstChart9_Issued.Close<br>
End With<br>
<br>
End Sub