Cleanup MS Query Macro Recorded Code

bs0d

Well-known Member
Joined
Dec 29, 2006
Messages
622
I'm curious what items are necessary in the Macro Recorded MS Query code. Below is an example. What items can you remove, and will it improve the speed of the query at all?

For example, can you alter the buffer size up or down? What are the implications? PageTimeout? And all the "FALSE" items below, what if you didn't list those properties at all?

Code:
With 
Sheets("GroupData").ListObjects.Add(SourceType:=0, Source:=Array(Array( _
"ODBC;DSN=MS Access Database;DBQ=L:\Historical\db\history.accdb;DefaultDir=L:\Production - Historical\db;DriverId=2" _
        ), Array("5;FIL=MS Access;MaxBufferSize=2048;PageTimeout=5;")), Destination:= _
        Sheets("GroupData").Range("$A$1")).QueryTable
.CommandText = sSQL
.RowNumbers = False
 .FillAdjacentFormulas = False
 .PreserveFormatting = False
 .RefreshOnFileOpen = False
 .BackgroundQuery = True
 .RefreshStyle = xlOverwriteCells
 .SavePassword = False
 .SaveData = True
 .AdjustColumnWidth = False
 .RefreshPeriod = 0
 .PreserveColumnInfo = True
 .ListObject.DisplayName = "QueryGroupData"
 .Refresh BackgroundQuery:=False
End With
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes

Forum statistics

Threads
1,223,247
Messages
6,171,007
Members
452,374
Latest member
keccles

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top