G
Guest
Hi everyone,
I hope that I can effectively articulate my issue here... here goes...
I am writing an analysis in VBA that requires the use of several queries,
many of whom are related, which have been writen entirely in VBA (ie. they
don't represent a query object that can be accessed via the database window.
I believe that the SQL statements are written correctly, but apparently, I'm
not actually running the query...only creating it. Here is a code example:
v_SQLEntityMasterjoin = "SELECT v_qryENTITY_CT_threshold.txtAENO,
v_qryENTITY_CT_threshold.txtMEGA_PROCESS,
v_qryENTITY_CT_threshold.txtMAJOR_PROCESS, " & _
"v_qryENTITY_CT_threshold.txtAUDIT_ENTITY,
v_qryENTITY_CT_threshold.AvgOfdblINHERENT_RISK,
v_qryENTITY_CT_threshold.AvgOfdblRESIDUAL_RISK,
v_qryENTITY_CT_threshold.AvgOfdblPROCESS_CRITICALITY, " & _
"v_qryENTITY_CT_threshold.AvgOfdblRESIDUALXCRITICALITY,
v_qryENTITY_CT_threshold.AvgOfdblTARGET_RISK,
v_qryENTITY_CT_threshold.SCORE_LEVEL_CT, v_qryENTITY_PY_threshold.txtAENO,
v_qryENTITY_PY_threshold.txtMEGA_PROCESS, " & _
"v_qryENTITY_PY_threshold.txtMAJOR_PROCESS,
v_qryENTITY_PY_threshold.txtAUDIT_ENTITY,
v_qryENTITY_PY_threshold.AvgOfdblINHERENT_RISK,
v_qryENTITY_PY_threshold.AvgOfdblRESIDUAL_RISK,
v_qryENTITY_PY_threshold.AvgOfdblPROCESS_CRITICALITY, " & _
"v_qryENTITY_PY_threshold.AvgOfdblRESIDUALXCRITICALITY,
v_qryENTITY_PY_threshold.AvgOfdblTARGET_RISK,
v_qryENTITY_PY_threshold.SCORE_LEVEL_PY " & _
"FROM v_qryENTITY_CT_threshold INNER JOIN v_qryENTITY_PY_threshold ON
v_qryENTITY_CT_threshold.txtAENO = v_qryENTITY_PY_threshold.txtAENO;"
Set v_qryENTITY_MASTERJOIN_ALLMATCHED = CurrentDb.CreateQueryDef(,
v_SQLEntityMasterjoin)
From what I can gather, v_qryENTITY_MASTERJOIN_ALLMATCHED is a query object
now, but how can I execute it?
I hope that I can effectively articulate my issue here... here goes...
I am writing an analysis in VBA that requires the use of several queries,
many of whom are related, which have been writen entirely in VBA (ie. they
don't represent a query object that can be accessed via the database window.
I believe that the SQL statements are written correctly, but apparently, I'm
not actually running the query...only creating it. Here is a code example:
v_SQLEntityMasterjoin = "SELECT v_qryENTITY_CT_threshold.txtAENO,
v_qryENTITY_CT_threshold.txtMEGA_PROCESS,
v_qryENTITY_CT_threshold.txtMAJOR_PROCESS, " & _
"v_qryENTITY_CT_threshold.txtAUDIT_ENTITY,
v_qryENTITY_CT_threshold.AvgOfdblINHERENT_RISK,
v_qryENTITY_CT_threshold.AvgOfdblRESIDUAL_RISK,
v_qryENTITY_CT_threshold.AvgOfdblPROCESS_CRITICALITY, " & _
"v_qryENTITY_CT_threshold.AvgOfdblRESIDUALXCRITICALITY,
v_qryENTITY_CT_threshold.AvgOfdblTARGET_RISK,
v_qryENTITY_CT_threshold.SCORE_LEVEL_CT, v_qryENTITY_PY_threshold.txtAENO,
v_qryENTITY_PY_threshold.txtMEGA_PROCESS, " & _
"v_qryENTITY_PY_threshold.txtMAJOR_PROCESS,
v_qryENTITY_PY_threshold.txtAUDIT_ENTITY,
v_qryENTITY_PY_threshold.AvgOfdblINHERENT_RISK,
v_qryENTITY_PY_threshold.AvgOfdblRESIDUAL_RISK,
v_qryENTITY_PY_threshold.AvgOfdblPROCESS_CRITICALITY, " & _
"v_qryENTITY_PY_threshold.AvgOfdblRESIDUALXCRITICALITY,
v_qryENTITY_PY_threshold.AvgOfdblTARGET_RISK,
v_qryENTITY_PY_threshold.SCORE_LEVEL_PY " & _
"FROM v_qryENTITY_CT_threshold INNER JOIN v_qryENTITY_PY_threshold ON
v_qryENTITY_CT_threshold.txtAENO = v_qryENTITY_PY_threshold.txtAENO;"
Set v_qryENTITY_MASTERJOIN_ALLMATCHED = CurrentDb.CreateQueryDef(,
v_SQLEntityMasterjoin)
From what I can gather, v_qryENTITY_MASTERJOIN_ALLMATCHED is a query object
now, but how can I execute it?