Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I'm using thecode below (derived using Record Macro, and them modified to
include file and directory name variables) to extract data from an Access database table and copy to a worksheet called "LinkedData3". It works, but it inserts the data, and so the sheet grows with every refresh. Could someone tell me how I can change the code to "replace" the full content of the sheet rather than "insert"? Regards... ================================================== ===== With Worksheets("LinkedData3").QueryTables.Add(Connecti on:=Array(Array( _ "ODBC;DSN=MS Access Database;DBQ=" & ReportFileName & ";DefaultDir= &" & DataFileDirectory & ";DriverId=281;FIL=MS Access;MaxBufferSize=2048;PageTimeout" _ ), Array("=5;")), Destination:=Worksheets("LinkedData3").Range("A1") ) .CommandText = Array( _ "SELECT `Agent Report`.datetime, `Agent Report`.groupNumber, `Agent Report`.agentNum, `Agent Report`.agentName, `Agent Report`.inCall, `Agent Report`.noCallAnswer, `Agent Report`.totalInNormalTime, `Ag" _ , _ "ent Report`.totalSigninTime, `Agent Report`.totalOutNormalTime, `Agent Report`.totalBusyTime, `Agent Report`.totalWrapupTime" & Chr(13) & "" & Chr(10) & "FROM `" & ReportFileName & "`.`Agent Report` `Agent Report`" & Chr(13) & "" & Chr(10) & "WHERE (`Agent Repor" _ , _ "t`.datetime={ts '" & ReportStartDate & " 00:00:00'} And `Agent Report`.datetime<{ts '" & ReportBeforeDate & " 00:00:00'})" & Chr(13) & "" & Chr(10) & "ORDER BY `Agent Report`.datetime" _ ) .Name = "Query from MS Access Database" .FieldNames = True .RowNumbers = False .FillAdjacentFormulas = False .PreserveFormatting = True .RefreshOnFileOpen = False .BackgroundQuery = True .RefreshStyle = xlInsertDeleteCells .SavePassword = True .SaveData = True .AdjustColumnWidth = True .RefreshPeriod = 0 .PreserveColumnInfo = True .Refresh BackgroundQuery:=False End With |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Import New Database Query (Union Query) in Spreadsheet | Excel Discussion (Misc queries) | |||
database query not showing foxpro database How I import data | New Users to Excel | |||
Replace ^ in web query result | Excel Worksheet Functions | |||
Anyone Else Use Database Query to Query Another Sheet in the Same Excel Workbook? | Excel Discussion (Misc queries) | |||
Anyone Else Use Database Query to Query Another Sheet in the Same Excel Workbook? | Excel Discussion (Misc queries) |