Results 1 to 4 of 4
  1. #1
    ser01 is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    Feb 2010
    Posts
    64

    Exporting query to excel does not refresh unless opened first.

    I have a database that exports a few queries to excel with a lot of data in them. Before the queries are exported, the tables that the data comes from, have a lot of data added to them since the last export. The actual query is never opened, since the only purpose they serve is to process the data a certain way before it is exporte. The whole process is handled by VBA.



    This does not seem to happen all the time. But at least some of the time, if the query is not opened before the export it does not export the updated data and instead what is exported is the data the query contained the last time it was opened. It all seems to be very inconsistent. Since this is all being handled by VBA it is no big deal to open the close the queries before the export. It is however rather inelegant.

    So I have a few questions to the more experienced users:

    1. Am correct the the queries do not update unless opened first? Is this an access bug, or normal behavior?
    2. If the answer above is YES, what other ways are there to forse the query to refresh programmatically without opening/closing them first?


    Thank you very much in advance.

  2. #2
    help_me_with_access is offline help_me_with_excel
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    262
    wow, strange issue. The first thing you should know is that all interface-based objects in access, when referenced by vba as a collection, have a "refresh" method. try using it at various places in your code.

    what exactly is handled by VBA? query object *creation* or just this export process?? were the objects created as static objects to just sit in the database window and never be replaced?? as, in you're *not" deleting and adding db window objects everytime the code runs, right??

    try using .refresh for the collections first. I would guess that would work fine. the other refresh that I've used before is RefreshDatabaseWindow(). that's a built-in function for access only, but I don't believe that has anything to do with the data. I believe that's only used to update the content list in the database window itself. but try it anyway.

    queries should *not* have to be opened in order to make new table data visible to it unless there's an outside intrusion that's got the query's attention from the start of your process to the end. like an object being locked, sort of...

  3. #3
    ser01 is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    Feb 2010
    Posts
    64
    This is very strange indeed. Like I said it does not happen all the time, but it does happen. I will try .Refresh of the query object and see what happens.
    Thank you for your reply.

  4. #4
    help_me_with_access is offline help_me_with_excel
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    262
    let us know either way.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Exporting query to Excel. Almost there
    By Wombat in forum Import/Export Data
    Replies: 13
    Last Post: 04-10-2012, 01:38 PM
  2. Exporting a Query to Excel
    By tcheck in forum Access
    Replies: 3
    Last Post: 07-22-2011, 05:00 PM
  3. Query Exporting to Excel
    By Coffee in forum Queries
    Replies: 2
    Last Post: 07-18-2011, 07:42 AM
  4. Exporting query to Excel file with password?
    By jvera524 in forum Access
    Replies: 0
    Last Post: 12-06-2010, 11:24 AM
  5. Exporting Query to Excel
    By jvera524 in forum Import/Export Data
    Replies: 0
    Last Post: 12-06-2010, 09:16 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums