PDA

View Full Version : Solved: Need to Store query results for use by another query



Hattonp
02-29-2012, 06:52 AM
I am new to VBA and need some help figuring out how to query a table, store the result (single field), then use that result for another query to get additional data from another table. I have not had luck with a nested query, can't figure out caching. The problem is the history table which stores multiple lines of data for the same reference number. I need to pull the unique reference numbers then use them to get detailed data from another table. I can get the data ok, just can't figure out how to use it for the other query.

The initial query looks like ths:
Select RPT_INCIDENT_HISTORY_PV.CALL_NUMBER
from RPT_INCIDENT_HISTORY_PV
WHERE RPT_INCIDENT_HISTORY_PV.HISTORY_DATE > '1/1/2012' AND RPT_INCIDENT_HISTORY_PV.Assign_Grp ='P&C Policy Svc TS'
GROUP BY RPT_INCIDENT_HISTORY_PV.CALL_NUMBER

This gets me what I need. How do I store it for use by the second query?

Thank you for your assistance. Patrick

mohanvijay
02-29-2012, 08:54 PM
SELECT * FROM TestTable WHERE TestTable.Number IN (Put above query here)