If it helps any, here's the VB code for the macro I built. Everywhere text indicates "period ending 011605", I'd like the reference to be cell B4 on the worksheet. (Sheet1)
Any ideas?
Thanks!
bobmc
Here's the VB code:
Sub zipdb()
'
' zipdb Macro
'
' Keyboard Shortcut: Ctrl+d
'
With ActiveSheet.QueryTables.Add(Connection:=Array(Array( _
"ODBC;DSN=MS Access Database;DBQ=C:\Documents and Settings\Bob McKeehen\My Documents\PastorGas\Sales2005\PGSales2005.mdb;DefaultDir=C" _
), Array( _
":\Documents and Settings\Bob McKeehen\My Documents\PastorGas\Sales2005;DriverId=25;FIL=MS Access;MaxBufferSize=2048;PageTimeout" _
), Array("=5;")), Destination:=Range("A7"))
.CommandText = Array( _
"SELECT `Period ending 011605`.`Total Amount`, `Period ending 011605`.`Customer Name`, `Period ending 011605`.ZIP, `Period ending 011605`.`Invoice Description`" & Chr(13) & "" & Chr(10) & "FROM `Period ending 011605` `Period endi" _
, "ng 011605`" & Chr(13) & "" & Chr(10) & "WHERE (`Period ending 011605`.`Total Amount`>20)")
.Name = "Query from MS Access Database_1"
.FieldNames = False
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = False
.RefreshStyle = xlOverwriteCells
.SavePassword = True
.SaveData = True
.AdjustColumnWidth = False
.RefreshPeriod = 0
.PreserveColumnInfo = True
.Refresh BackgroundQuery:=False
End With
End Sub