How do I create a Pass Through query with a date prompt and then load it into a local table (make table)?
I want to run this in access and before it goes to the server I want the query to prompt me for a date to enter as criteria and then when the results are returned I want them stored in a local table for further processing and joining on other local tables and analyis.
I know there is a way to do this through VBA. Below is some sample code but I am not seeing the part where I can store this into a local table in MS Access.
/* SAMPLE CODE...not mine*/
Dim db As DAO.Database
Dim qdExtData As QueryDef
Dim strSQL As String
Set db = CurrentDb
strSQL = "SELECT * FROM TBL WHERE FIELD1 = " &
[Forms]![Form1]![Combo6]
Set qdExtData = db.CreateQueryDef("QRY_PASS_THROUGH")
qdExtData.Connect = "ODBC;DSN=???;UID=???;PWD=???;DBQ=???;"
qdExtData.SQL = strSQL
qdExtData.Close
db.Close
Set db = Nothing
/* SAMPLE CODE...not mine*/
BACKGROUND INFO: The reason I am using a Pass through query was because I copied a large amount of SQL from Peoplesoft query which includes some CASE statements and other SQL components that the Jet engine can’t process but the Oracle server I am sending it to can.
Why don’t you try
However, this will work once and then you’ll have to deal with deleting the previous query and table since the code above creates new ones.
A better solution is to create both the PassThruQuery and the table in development and then just reset them when you run your code: