Excel query (Access) refresh error - -2147217848 (80040e4e)

Paul_mcc

New Member
Joined
Dec 9, 2012
Messages
2
Hi all,
Hoping you could help me with the following.

I have an Excel spreadsheet that draws in queries from an Access database using OLEDB.

There are many queries, so rather than refresh them manually I built a macro to do so.

I recorded myself manually refreshing one query and came up with the following code which I copy/pasted 60 or so times, changing the cell reference so it would update each different query:
Range("A4").Select
Selection.ListObject.QueryTable.Refresh BackgroundQuery:=False

However when it gets towards the 55th query or so it gives me the error message "2147217848 (80040e4e)" and calls it an "unspecified error".

Some explanation and help would be hugely appreciated. I can't understand why it would work when I refresh it manually but not via a macro. And sometimes a query that refreshes fine in one run of the macro won't refresh properly the next time.
The connection string is as follows:
Provider=Microsoft.ACE.OLEDB.12.0;User ID=Admin;Data Source=C:\Users\Toshiba\Desktop\Wholesale inputs database - Scenario 1.accdb;Mode=Share Deny Write;Extended Properties="";Jet OLEDB:System database="";Jet OLEDB:Registry Path="";Jet OLEDB:Engine Type=6;Jet OLEDB:Database Locking Mode=0;Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Global Bulk Transactions=1;Jet OLEDB:New Database Password="";Jet OLEDB:Create System Database=False;Jet OLEDB:Encrypt Database=False;Jet OLEDB:Don't Copy Locale on Compact=False;Jet OLEDB:Compact Without Replica Repair=False;Jet OLEDB:SFP=False;Jet OLEDB:Support Complex Data=False;Jet OLEDB:Bypass UserInfo Validation=False.

Thanks!
Paul
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.

Forum statistics

Threads
1,223,718
Messages
6,174,082
Members
452,542
Latest member
Bricklin

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top