Access database error

F

Fredrik WG

I have sporadically found an error when accessing an access database from
Excel VBA, sometimes I get double entries (lines) in Excel when there is only
one entriy in Access database. The double entriy I see are just a copy of an
existing line.

Database are located in house on network drive.

Question: Does anyone know the cause of this error / behaviour? The solution
today is to verify that no double entries exists, and if it does, promt
operator to re-run macro until it pass.

VBA Code:
With ActiveSheet.QueryTables.Add(Connection:=Array(Array( _
"ODBC;DSN=MS Access Database;DBQ=" & FileToOpen & ";FIL=MS
Access;MaxBufferSize=2048;PageTimeout=5;" _
)), Destination:=Range("A1"))
.CommandText = Array( _
"SELECT BOAT.ShortID, BOAT.Rev, BOAT.TestGroup, BOAT.MPPoint,
BOAT.MPDescription, BOAT.LtLow, BOAT.LtHigh, BOAT.Meas, BOAT.Unit,
BOAT.Cause, " _
, _
"BOAT.CompName, BOAT.Action, BOAT.Comments, BOAT.TSResp, BOAT.Pos,
BOAT.CompNumb, BOAT.RepairHistory, BOAT.RepCnt, BOAT.Status, BOAT.DateUpdate,
" _
, _
"BOAT.IR, BOAT.DateStamp, BOAT.ID, BOAT.IDNumber, BOAT.MPGroup,
BOAT.CustomerCom, BOAT.Loc FROM BOAT ORDER BY BOAT.IDNumber, BOAT.Loc")

.Name = "Query from MS Access Database"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = False
.AdjustColumnWidth = True
.RefreshPeriod = 0
.PreserveColumnInfo = True
.Refresh BackgroundQuery:=False

End With
 

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

Top