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

  • SEARCH
  • Home
  • 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 7816409
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T05:51:30+00:00 2026-06-02T05:51:30+00:00

I have an Access Database and I’m using a pass through query to return

  • 0

I have an Access Database and I’m using a pass through query to return records from an AS400 table. The connection string and pass through query work fine, but now I’m trying to populate the results of the p-t query into a local table within the db and my code is timing out. This is my first attempt at ADO so I’m disclaiming my code with “I’m not 100% sure what I’m doing!”. Could you look at this and see if there is something obvious that I’m doing wrong? Any direction would be appreciated. Thank you in advance.

    Sub mod_ADODBConnect()
      Const NewTableName = "MyNewTable"
      Dim cn As ADODB.Connection
      Dim rs As ADODB.Recordset
      Dim db As DAO.Database
      Dim sSQL1 As String
      Dim sSQL2 As String

      sSQL1 = "SELECT ITMNUM, ITMDS, ITPKDS, MJCMCD, SBCMCD, STATUS, PRITIN, OGEXDT         from PDBLLIB007.BLPMST07"
      sSQL2 = "INSERT INTO ' & NewTableName & ' SELECT [" & sSQL1 & "].* from [" & sSQL1 & "]"

      Set cn = New ADODB.Connection
      cn.Open "Driver={Client Access ODBC Driver (32-bit)};" & _
        "System=DC007; Uid=XXXXX; Pwd=XXXXXX; MgDSN=0; ConnType=2;" & _
        "BlockSize=512; MaxFieldLen=2048; LazyClose=1; Prefetch=1; QueryTimeOut=0;     Translate=1"

     Set rs = New ADODB.Recordset
     rs.Open sSQL1, cn, adOpenDynamic, adLockOptimistic

     Do While Not rs.EOF
        rs.MoveNext
     Loop

   Set db = CurrentDb
   db.Execute ("sSQL2")

   rs.Close
   cn.Close

   Set rs = Nothing
   Set cn = Nothing
   Set db = Nothing
   End Sub
  • 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-02T05:51:31+00:00Added an answer on June 2, 2026 at 5:51 am

    You have a pass-through query which works fine and returns the rows you want. Now you want to store those rows in a new local (Jet/ACE) table. Seems to me a simpler approach would be to use the pass-through as the data source in a new “make table” query.

    SELECT * INTO MyNewTable FROM YourPassThruQuery;
    

    Oops, looks like you meant to append those rows to an existing table.

    INSERT INTO MyNewTable
    SELECT * FROM YourPassThruQuery;
    

    If the table structures don’t match, you can use field lists for both tables.

    INSERT INTO MyNewTable (fld1, fld2)
    SELECT first_field, second_field FROM YourPassThruQuery;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an access database with a table. This table keeps getting records deleted,
I have an Access database which has a table with around 6k records. When
I have an Access database in which I drop the table and then create
I have an access database, with a query made. I need to automate it
I have an access database with 3 tables. People Gifts PeopleGifts Using VS 2008,
I have a Microsoft Access database query that I'm trying to import into a
I have an access database table that has an autoNumber column, and the table
I have an Access database I am querying with SQL from VB .NET. The
I have an (access) database table which contains data I would like to populate
Let's say I have an Access database table that has 2 columns: one is

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.