Running pre-defined queries and save the result in an excel file

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mborhanian
    New Member
    • Mar 2010
    • 1

    Running pre-defined queries and save the result in an excel file

    Hello,

    As part of an application that I am trying to create thru MS Access, the user enters few parameters and based on that I would like the result of some predefined queries to be saved in an excel file (in separate worksheets). I have created a table which lists the name of queries in one field and user's parameters in a separate fields. When I select a command button, I like the queries run one at the time (go thru each record find the query in the table) and the results are saved in an excel file. For example, in the table below if teh user enters 1 and A, then Query-A-1 and Query-A-2 should be run and their records be saved in one excel file. I can do this by creating multple IF - statements. However, I would like to know if it is possible to do this in a differnt way (i.e one loop)

    User Data 1 User Data 2 Queries
    1 A Query-A-1
    1 A Query-A-2
    2 B Query-B-1
    2 B Query-B-2

    Thank you in advance.
  • Jim Doherty
    Recognized Expert Contributor
    • Aug 2007
    • 897

    #2
    Originally posted by mborhanian
    Hello,

    As part of an application that I am trying to create thru MS Access, the user enters few parameters and based on that I would like the result of some predefined queries to be saved in an excel file (in separate worksheets). I have created a table which lists the name of queries in one field and user's parameters in a separate fields. When I select a command button, I like the queries run one at the time (go thru each record find the query in the table) and the results are saved in an excel file. For example, in the table below if teh user enters 1 and A, then Query-A-1 and Query-A-2 should be run and their records be saved in one excel file. I can do this by creating multple IF - statements. However, I would like to know if it is possible to do this in a differnt way (i.e one loop)

    User Data 1 User Data 2 Queries
    1 A Query-A-1
    1 A Query-A-2
    2 B Query-B-1
    2 B Query-B-2

    Thank you in advance.
    Yes you can loop through records in either a table or query according to preset logic and using 'Office' automation, save the results to an excel file.

    Yes this can be done where it is on separate sheets again using automation techniques

    What is your approach to this, what have you coded yourself to make this work?

    If you show something done yourself I am sure others will be happy to contribute rather than just give a solution to this

    Comment

    • NeoPa
      Recognized Expert Moderator MVP
      • Oct 2006
      • 32663

      #3
      Application Automation would be a good starting point for your work.

      Comment

      Working...