Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Error Querying Access Database From Excel

Hi,

Using Excel 2000 (9.0.4402 SR-1)

I am querying an access database and the first time I run a query
everything works fine, if I try a second time the query does not run
(creating an error which I capture), I have to close and then re-open
Excel in order to run it again

Anyone have any idea why this happens ...

Below is the code


wFolder = "\\Kels-dsk-001\Apps\Raymond Allan\Access"
sDir = "`\\Kels-dsk-001\Apps\Raymond Allan\Access\Item Branch`"

FamId = Main.mFamId

On Error GoTo Data_Error

With ActiveSheet.QueryTables.Add(Connection:= _
"ODBC;DSN=MS Access Database;DBQ=" & wFolder & "\Item
Branch.mdb;DefaultDir=" & wFolder & _
";DriverId=25;FIL=MS Access;MaxBufferSize=2048;PageTimeout=5;"
_
, Destination:=Range("A1"))
.CommandText = Array( _
"SELECT Sheet1.`2nd Item Number`, Sheet1.Description,
Sheet1.`Leadtime Level`, " _
, "Sheet1.`Reorder Qty Min`, Sheet1.`Order Multiple`, " _
, "Sheet1.`Safety Stock`, Sheet1.`Standard Cost`,
Sheet1.`Expected Cost` " _
, "FROM " & sDir & ".Sheet1 Sheet1 " _
, "WHERE (Sheet1.`Sales Catalog Section`=" & FamId & ") " _
, "ORDER BY Sheet1.`2nd Item Number`")
.Name = "Item_Branch_Info"
.FieldNames = True
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.AdjustColumnWidth = True
.RefreshPeriod = 0
.Refresh BackgroundQuery:=False
End With

TIA
Raymond Allan

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Error in querying data from MS Access aemAndy Excel Discussion (Misc queries) 1 April 16th 07 06:54 PM
Querying an Access Database from Excel VBA Chaplain Doug Excel Programming 3 November 10th 05 04:24 PM
Database access & querying Steve[_78_] Excel Programming 7 September 12th 05 02:21 PM
Querying Data from Secured Access Database with VBA VBA Dabbler[_2_] Excel Programming 9 February 18th 05 09:15 PM
Querying Access Database Edgar Thoemmes Excel Worksheet Functions 1 December 15th 04 01:58 PM


All times are GMT +1. The time now is 04:39 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"