04 GetQueryTable - AndrewMB2/Logic-Architect-for-Excel-VBA GitHub Wiki
GetQueryTable method
Creates a new query table on a worksheet. Returns True if successful, otherwise False.
Applies to
| TableData | ArrData | RsetData | Xdata | XShared |
|---|---|---|---|---|
| ✓ |
Parameters
| Name | Type | Description |
|---|---|---|
| SQL | String | SQL statement used to select data for the query table. |
| TableRange | Range | First cell where the query table should be placed. |
| TableName | String (optional) | Name of the query table. |
| TableStyle | String | The name of the table style to be applied to the query table. |
| AdjustColumnWidth | Boolean (optional) | True (default) adjusts column widths to fit the data. |
GetQueryTable creates a query table at the location specified by the TableRange parameter. Any existing query table on this worksheet is first deleted. Any table with the name specified by the TableName parameter is first deleted.
If the RsetData object is already connected to a database, the existing connection string is used, otherwise (for supported databases) the GetConnectionString method must be used first.
The query table is set not to maintain the connection (the method can be rerun if required).
Query tables are useful to obtain a quick view of query results, though for reporting, copying to a TableData object provides much more control over the output.