QueryGetDataDialog Function

Description

Builds a new query. Equivalent to the Get External Data command (Data menu).

This function is contained in the Microsoft Query add-in. Before you use the function, you must establish a reference to the add-in using the References command (Tools menu).

Syntax

QueryGetDataDialog(connectionStr, queryText, keepQueryDef, fieldNames, rowNumbers, destination, execute)

connectionStr

Required. A string that contains database connection information, such as the data source name, user ID, and passwords, necessary to make a SQL connection to an external data source. For example, "DSN=Myserver; Server=server1; UID=dbayer; PWD=buyer1; Database=nwind".

queryText

Required. A string that contains the SQL language query to be run on the data source.

keepQueryDef

Optional. If True or omitted, preserves the query definition. If False, the query definition is lost and the data from the query is no longer a data range.

fieldNames

Optional. If True or omitted, places field names from Microsoft Query into the first row of the data range. If False, the field names are discarded.

rowNumbers

Optional. If True, places row numbers from Microsoft Query into the first column in the data range. If False or omitted, the row numbers are discarded.

destination

Optional. The destination for the returned data, as a Range object. If destination is in a data range then that data range is changed to reflect the new SQL query. The default destination is the active cell or the selection.

execute

Optional. If True or omitted, the query is run immediately. If False, the query text is added to a buffer and the query is not run until a subsequent QueryGetData function call with the execute argument set to True. When this occurs, Microsoft Query runs all query text in the buffer.

See Also

QueryGetData Function, QueryRefresh Function.