Runtime Error .Refresh

M

Michelle

I have the folloing code it worked fine up till today and now it gives me a
Runtime Error and when I debug it goes to the .Refresh BackgroundQuery: =
False line of the following code.

Sub Update()
Dim stAppName As String
stAppName = "H:\common\count\Update.bat"
Call Shell(stAppName, 1)

Sheets("Master").Visible = True
Sheets("Master").Select
Range("A1:AK5000").Select
Selection.ClearContents
Range("A1").Select
With ActiveSheet.QueryTables.Add(Connection:= _
"ODBC;DSN=dBASE
Files;DefaultDir=H:\common\count;DriverId=533;MaxBufferSize=2048;PageTimeout=5;" _
, Destination:=Range("A1"))
.CommandText = Array( _
"SELECT INMTINFO.IN_INMNUM, INMTINFO.IN_NAME, INMTINFO.IN_RACE,
INMTINFO.IN_CSLR, INMTINFO.IN_CUSLVL, INMTINFO.IN_STATUS,
INMTINFO.IN_BIRTHDT, INMTINFO.IN_RELIGIO, INMTINFO.IN_FACRCVD,
INMTINFO.IN_DOCR" _
, _
"CVD, INMTINFO.IN_RCVDFAC, INMTINFO.IN_EFFDATE, INMTINFO.IN_SNTCLAS,
INMTINFO.IN_MINDATE, INMTINFO.IN_MAXDATE, INMTINFO.IN_MINSNT,
INMTINFO.IN_MAXSNT, INMTINFO.IN_CMTCNTY, INMTINFO.IN_OFFENSE, INMTINFO" _
, _
".IN_PERMLOC, INMTINFO.IN_LOCDESC, INMTINFO.IN_BLDING,
INMTINFO.IN_SECTION, INMTINFO.IN_CELLDRM, INMTINFO.IN_BEDNUM,
INMTINFO.IN_HONOR, INMTINFO.IN_PRIMPGP, INMTINFO.IN_WA1, INMTINFO.IN_WA1STRT,
INMTIN" _
, _
"FO.IN_WA1CS, INMTINFO.IN_MEDSTR, INMTINFO.IN_MEDEND,
INMTINFO.IN_CRESSTR, INMTINFO.IN_CRESEND, INMTINFO.IN_DAOFF,
INMTINFO.IN_SEXOFF, INMTINFO.IN_CNAME" & Chr(13) & "" & Chr(10) & "FROM
INMTINFO INMTINFO" _
)
.Name = "Query from dBASE Files"
.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
 
T

Template examples - don''t bother

Well, to begin with, you are setting the Background query to both TRUE and
FALSE.

.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True<-----------------------here
.RefreshStyle = xlInsertDeleteCells
.SavePassword = True
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.PreserveColumnInfo = True
.Refresh BackgroundQuery:=False <----------------and here

Set either the .Backgroundquery property to TRUE or FALSE or , on the
..Refresh just add TRUE or FALSE - .Refresh False.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top