Results 1 to 4 of 4
  1. #1
    johnseito is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2013
    Posts
    419

    Access table, created complex query, export it back to desktop via VBA

    I used VBA to load data into access table.


    I created a complex query that manipulate the table into forms that I want.
    I use VBA to export this query back onto a desktop in excel sheet.

    After doing that, the query SQL code in the query is gone.
    When I click to open the query, it says: Query must have at least one destination field.

    Not sure if I should post this in the query section or the VBA.
    Please advise !

  2. #2
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,397
    not sure it matters which section, but what is your question? If it is why has the sql code gone? you need to provide information about how it was created, saved etc -

  3. #3
    johnseito is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2013
    Posts
    419
    I have a table in Access, table A. I manipulate it (using query statements) pretty much using iif, grouping them together, sum them together and then join to itself
    from subquery to query etc.
    The final query TOA. I use VBA to export it back to the desktop, everytime I do this, the query SQL code just disappears and when I tried to open the query the message is
    "Query must have at least one destination field."
    The only code in the Query SQL view is
    SELECT;

    Not sure why

    The code to export it out is
    Code:
    DoCmd.OutputTo acOutputQuery, "TOA", acFormatXLSX, pth, False

    If I don't use the VBA code to export it out, and just click on the query to view it, either design view or datasheet view. It works fine and the result is just what I want.

  4. #4
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,716
    John,

    What exactly do you want to do with the data in the table?

    It appears that the SQL of your query is simple "SELECT".
    See this for basic Select query.

    It appears you have not saved the query(s).
    Good luck.

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

Similar Threads

  1. Replies: 3
    Last Post: 04-07-2016, 04:36 AM
  2. Replies: 1
    Last Post: 03-21-2015, 11:55 AM
  3. Replies: 7
    Last Post: 04-25-2013, 03:47 PM
  4. Replies: 2
    Last Post: 09-29-2009, 10:25 AM
  5. Security icon created on desktop !!!
    By wasim_sono in forum Security
    Replies: 1
    Last Post: 02-07-2006, 09:42 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