Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8073941
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T14:29:51+00:00 2026-06-05T14:29:51+00:00

How do I create a Pass Through query with a date prompt and then

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T14:29:53+00:00Added an answer on June 5, 2026 at 2:29 pm

    Why don’t you try

    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 
    
    'Now use the Pass Thru query above as the data source for the Make table query below 
    strSQL = "Select QRY_PASS_THROUGH.* INTO tblPassThruResults FROM QRY_PASS_THROUGH" 
    db.Execute strSQL 
    
    db.Close 
    Set db = Nothing 
    

    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:

    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] 
    
    'Reset the SQL statment for the query 
    Set qdExtData = db.QueryDefs("QRY_PASS_THROUGH") 
    qdExtData.SQL = strSQL 
    'Empty the table 
    strSQL = "DELETE * FROM tblPassThruResults"
    db.Execute strSQL 
    
    'Now use the Pass Thru query above to reload the table 
    strSQL = "INSERT INTO tblPassThruResults Select QRY_PASS_THROUGH.* FROM QRY_PASS_THROUGH" 
    db.Execute strSQL 
    
    db.Close 
    Set db = Nothing 
    Watch out for your date string in the query. You may need to add delimiters. Top
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to run create 4 objects by pass different arguments and calling the
I want to create a alias method in ruby and pass parameters to this.
I am running an SQL pass-through query in SAS. When I run it on
I have a testdata like this: DROP TABLE SELECT_PASS; CREATE TABLE SELECT_PASS(ID INT(20),TESTCASE VARCHAR(20),RESULT
I'm trying to pass my sqlite database through to a function and then through
I'm trying to pass a dynamic, user created object through AJAX to some C#.
I trying to create a json object and pass that object to template.render(JSONObj) ,
I am about to create a ViewModel to pass some data to a View.
how can I create a dynamic lambda expression to pass to use in my
I would like to create some sort of function where you pass in a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.