I have been trying to get this SQL string statement to run for some time now.
The current error is:
You tried to execute a query that does not include the specified expression 'Recruiter' as part of an aggregate function. (Error 3122)
I am assuming this is due to the code thinking 'recruiter' is a summed value. I am pretty new to SQL and Access VBA programming, so any help would be nice.
The current error is:
You tried to execute a query that does not include the specified expression 'Recruiter' as part of an aggregate function. (Error 3122)
I am assuming this is due to the code thinking 'recruiter' is a summed value. I am pretty new to SQL and Access VBA programming, so any help would be nice.
Code:
strSQLc = "SELECT [tbl Officer Prospecting Applicant Log].[Recruiter], " & _
" Format([Contact Date],'mmm-yy') AS [Contact Month Range], " & _
" Sum(IIf([Initial Contact] = 'Local Lead' Or [Initial Contact] = 'National Lead' Or [Initial Contact] = 'Phone Lead',1,0)) AS [Contact Leads] ," & _
" Sum(IIf([Initial Contact]= 'Email' ,1,0)) AS [Contact Email] ," & _
" Sum(IIf([Initial Contact] = 'Applicant Referral' Or [Initial Contact] = 'COI/Counselor' Or [Initial Contact] = 'Colliegate Referal' Or [Initial Contact] = 'Recuiter Referrral' Or [Initial Contact] = 'Referral Other Service' Or [Initial Contact] = 'Pro Navy',1,0)) AS [Contact Referrals] ," & _
" Sum(IIf([Initial Contact] = 'Presentation/OHARP/SEMINAR',1,0)) AS [Contact Presentations] ," & _
" Sum(IIf([Initial Contact] = 'Personally Developed Contact',1,0)) AS [Contact PDC] ," & _
" Sum(IIf([Initial Contact] = 'Walk In',1,0)) AS [Contact Walk In/Mail Out] " & _
" FROM [tbl Officer Prospecting Applicant Log] " & _
" WHERE [Recruiter] = '" & str_recr & "' " & _
" GROUP BY Format([Contact Date],'mmm-yy')" & _
" HAVING [Contact Date] = '" & mon1 & "' " & _
" OR [Contact Date] = '" & mon2 & "' " & _
" OR [Contact Date] = '" & mon3 & "'; "