+ Reply to Thread
Results 1 to 5 of 5

Import Query in Access to Excel

  1. #1
    Registered User
    Join Date
    01-18-2005
    Posts
    62

    Import Query in Access to Excel

    Dear all,

    I have a query in Access and I would like to import data to Excel.

    I am trying the below macro but it only works with Table.

    INVREGISTER is table, if it is replaced by Query named Qry1, it does not work.

    Is there anyway to import directly from Query to Excel.

    Thank you very much

    Nam

    Please Login or Register  to view this content.
    Last edited by rylo; 11-13-2008 at 12:59 AM. Reason: added code tags

  2. #2
    Forum Expert
    Join Date
    01-15-2007
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    6,591
    Hi

    Ran your code only changing the name to match a query I have, and it worked correctly.

    Are you sure you are using the correct query name?

    rylo

  3. #3
    Registered User
    Join Date
    01-18-2005
    Posts
    62
    Hi Rylo,

    Thanks for your reply. I'm sure that I relace the correct name of query, however it does not work.

    Nam

  4. #4
    Registered User
    Join Date
    01-18-2005
    Posts
    62
    Hi Rylo,

    I have tested and found out that

    If the query is

    SELECT INVREGISTER.Reference, INVREGISTER.InvNo, INVREGISTER.OurRef, INVREGISTER.Creditor
    FROM INVREGISTER
    WHERE (((INVREGISTER.Creditor) Like "SCHLUM*"));

    The macro does not work

    If the query is

    SELECT INVREGISTER.Reference, INVREGISTER.InvNo, INVREGISTER.OurRef, INVREGISTER.Creditor
    FROM INVREGISTER
    WHERE (((INVREGISTER.Creditor)="SCHLUMBERGER SEACO, Inc."));

    The macro works perfectly

    I may think that there is a difference of SQL in Excel and Access

    Do you have any ideas?

    Nam

  5. #5
    Forum Expert
    Join Date
    01-15-2007
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    6,591
    Nam

    I see what you mean.

    Try putting the sql directly into the macro rather than pulling from an existing query. Change your rs.open to something like

    Please Login or Register  to view this content.

    rylo

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1