Not sure what I'm doing wrong here. According to the debugger, the problem is in the "Set rst" line.
Code:
Function AnythingThere(strCurrentSite As String)
Dim strSQL As String
Dim rst As DAO.Recordset
Dim intRecordCount As Integer
strSQL = "SELECT Analyzer.[Revenue Under Goal (Lifetime)], Analyzer.[Order Line], Analyzer.[End Date],"
strSQL = strSQL + "Analyzer.[Order ID] , Analyzer.[Billing Method] FROM Analyzer WHERE "
strSQL = strSQL + "(((Analyzer.[Revenue Under Goal (Lifetime)])>0)"
strSQL = strSQL + "AND ((Analyzer.[End Date])<=(Date())+7) AND ((Analyzer.[Billing Method])='Delivery')"
strSQL = strSQL + "AND ((Analyzer.[Internet Site])=" & strCurrentSite & "))"
Debug.Print strSQL
' Run a query to see whether it comes back with anything. If not, then no need to make a corresponding table for that site.
Set rst = CurrentDb.CreateQueryDef("", strSQL).OpenRecordset
intRecordCount = rst.RecordCount
AnythingThere = intRecordCount
rst.Close
Set rst = Nothing
End Function