I have a snipet of my VBA project below. The project runs fine, what I'm trying to do is add one more layer to it. What procedure would I use to assign a "query name" to the sql string below?
Ultimately I would like to run another query after this one executes which will return a single COUNT of the total number of records selected in the first query. I want to eventually pass this count to a txtbox in my project.
I've done this with the queries in ACCESS, though trying to do this programatically within VBA.
db.Execute "SELECT DISTINCT ths.ACCOUNTID, ioa.ASSETMAJORCLSS, ioa.MINALLOC, ioa.MAXALLOC, sum(val(ths.INSTCONCENTRATION)) " & _
"FROM & tablename & AS ths, tblIOAllocation AS ioa " & _
"WHERE ioa.INVSOBJECTIVE=ths.INVSOBJECTIVECD and ioa.ASSETMAJORCLSS=ths.ASSETCODE and ths.ASSETCODE='1' " & _
"GROUP BY ths.ACCOUNTID, ioa.ASSETMAJORCLSS, ioa.MINALLOC, ioa.MAXALLOC " & _
"HAVING sum(val(ths.INSTCONCENTRATION))>=ioa.minalloc and sum(val(ths.INSTCONCENTRATION))<=ioa.maxalloc "), dbFailOnError