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 8582603
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T21:19:59+00:00 2026-06-11T21:19:59+00:00

I’m trying to update a local Access 2010 table by pulling data from a

  • 0

I’m trying to update a local Access 2010 table by pulling data from a remote PostgreSQL database using an ODBC connection. When I manually specify WHERE conditions in the Access update query, I can see on the database server that a limited number of rows are being passed to Access. However, when I make the WHERE condition dynamic—based on the last row in the local Access table—the entire table appears to be pulled into Access and the condition applied in memory (I presume, since it never completes).

For example, this query only fetches the 2012 rows from from the remote database, and I can see the WHERE clause on the remove server:

INSERT INTO local (dt, latitude, longitude)
SELECT dt, latitude, longitude
FROM remote_odbc
WHERE remote_odbc.dt > #2011-12-31 23:59:59#;

But what I really want is for access to look at the last datetime (dt) in the local table and only retrieve those rows from the remote database.

This is what I tried:

INSERT INTO local (dt, latitude, longitude)
SELECT dt, latitude, longitude
FROM remote_odbc, (SELECT max(dt) AS max_dt FROM local) AS sub
WHERE remote_odbc.dt > max_dt;

When I do this, the query being run on the server has no WHERE clause in it at all, which makes me think that Access is retrieving the entire remote table, and then applying the WHERE clause locally. The table is too large and the Internet is too slow for this to be practical.

How can I re-write my update query so it will only retrieve the rows I want over the ODBC link?

  • 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-11T21:20:00+00:00Added an answer on June 11, 2026 at 9:20 pm

    “FROM remote_odbc, (…) AS sub” makes me suspect it’s the cause of the problem. Try this INSERT statement instead …

    INSERT INTO local (dt, latitude, longitude)
    SELECT dt, latitude, longitude
    FROM remote_odbc
    WHERE remote_odbc.dt > DMax("dt", "local");
    

    Since you reported that suggestion didn’t restrict the server rows sent back to Access, use a parameter query to put a single Date/Time value in the WHERE clause. The following procedure may not fit nicely in your current application context, but I’m offering it as more like a diagnostic test … to see if we can get something to work correctly.

    Dim db As DAO.Database
    Dim qdf As DAO.QueryDef
    Dim dteLast As Date
    Dim strInsert As String
    
    dteLast = DMax("dt", "local")
    Debug.Print "dteLast: " & dteLast
    Set db = CurrentDb
    strInsert = "PARAMETERS which_date DateTime;" & vbCrLf & _
        "INSERT INTO local (dt, latitude, longitude)" & vbCrLf & _
        "SELECT dt, latitude, longitude" & vbCrLf & _
        "FROM remote_odbc" & vbCrLf & _
        "WHERE remote_odbc.dt > which_date;"
    Debug.Print "strInsert:" & vbCrLf & strInsert
    Set qdf = db.CreateQueryDef("", strInsert)
    qdf.Parameters("which_date") = dteLast
    qdf.Execute dbFailOnError
    Set qdf = Nothing
    Set db = Nothing
    

    Note that code is untested since I don’t have your tables and sample data to work with. However, it does compile without error from Access 2007.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I have a view passing on information from a database: def serve_article(request, id): served_article
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the

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.