Name

querytable.Refresh([BackgroundQuery])

Synopsis

Refreshes a query table from its data source. Returns True if the refresh was submitted successfully, False if the user canceled the refresh.

Argument

Description

BackgroundQuery

True refreshes the data asynchronously; False refreshes the data synchronously. Default is True.

Most types of query table store connection and data source information that is used by Refresh. The exception is recordset queries—you must set a new recordset before calling Refresh for query tables based on recordsets. See the Recordset property in Chapter 12 for an example.

When refreshing asynchronously, check the Refreshing property before calling Refresh. Otherwise, pending refreshes will cause an error. The following code cancels any pending asynchronous refresh before refreshing a query table:

    If qt.Refreshing Then qt.CancelRefresh
    qt.Refresh

Get Programming Excel with VBA and .NET now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.