+ Reply to Thread
Results 1 to 5 of 5

Difference between connections and queries using VBA to create Power Query

  1. #1
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,940

    Difference between connections and queries using VBA to create Power Query

    Hi Guys,

    i am using code from here:

    https://www.excelcampus.com/vba/powe...ly-all-tables/

    Please Login or Register  to view this content.
    Can anybody explain why to create connection to created query and confirm that connection name is hidden in excel workbook memoery?

    Query is just query in PQ. But why to add connection to it?

    Best,
    Jacek

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,782

    Re: Difference between connections and queries using VBA to create Power Query

    Query is just query in PQ.
    What EXACTLY do you mean by this statement? How do you define 'just a query'?

    My understanding of the way PQ works is this (and this may be rudimentary): if you create a query and load it to connection only (there's a clue in this), then it's only the parameters of the query (the steps taken within it) that are saved. The query tables themselves have to be recreated when you open the workbook.

    Someone with a deeper understanding may be able to give more detail, but in essence, that's how connection only queries refresh.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  3. #3
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,940

    Re: Difference between connections and queries using VBA to create Power Query

    Hi Ali,

    thank you very much.

    What EXACTLY do you mean by this statement? How do you define 'just a query'?
    I mean that this is just a view from some kind of source range.

    And what is strange connection is also created here:

    Please Login or Register  to view this content.

    ----
    The query tables themselves have to be recreated when you open the workbook
    to fully understand.
    Connection has to be done together with queries.add statement ? in order to have proper source connected to PQ?
    I tested it:

    I commented this part of code:

    Please Login or Register  to view this content.
    closed and open workbook and....nothing change. Still i have connection only created.

    Hmm,
    Best,
    Jacek

  4. #4
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,911

    Re: Difference between connections and queries using VBA to create Power Query

    My understanding is that yes, a query is just a query in PQ. Like a query in Access, it's basically just a set of instructions that will do something when executed. A connection is the link between that query and Excel. It allows you do things like building a pivot table connected to that query, or returning the data to a table. So you can delete the connection, but then Excel cannot actually use that query, since it no longer has any link to it. That may make sense if you have queries that are essentially helper queries - e.g. sources for a merge query - that don't need to be accessed from Excel.
    Rory

  5. #5
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,940

    Re: Difference between connections and queries using VBA to create Power Query

    Thank you very much for help and support,
    It it clear!

    Jacek

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] delete power query connections for the copy workbook
    By bujaber10 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-18-2020, 04:30 PM
  2. Replies: 4
    Last Post: 02-17-2020, 06:03 AM
  3. Power Query - How to refresh queries?
    By ypurcaro in forum Excel General
    Replies: 11
    Last Post: 02-11-2019, 06:47 PM
  4. [SOLVED] Use VBA to remove all power query connections with DocumentInspector
    By beaglesBuddy in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-27-2018, 05:17 PM
  5. Replies: 3
    Last Post: 04-20-2018, 08:30 AM
  6. Does My VBA Code To Refresh CSV Power Query Connections Need To Change for MySQL Queries?
    By beaglesBuddy in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-11-2017, 02:57 PM
  7. Power Query - Storing and Connections
    By James McEwan in forum Excel General
    Replies: 0
    Last Post: 08-09-2016, 08:19 AM

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