I am executing a query and bringing the data into Excel. I just started to get this error and I am not sure why. The error is thrown at .Refresh BackgroundQuery:=False and says Application defined error. It seems to stem from one particular query. I am able to execute others within the same database using the same code (just different commandtext).The microsoft message when trying to query the data manually is: Data could not be retrieved from the dtabase. Check the database server or contact your ..blah. Any input would be very helpful.
Code:
With .ListObjects.Add(SourceType:=0, Source:=Array( _
"OLEDB;Provider=Microsoft.ACE.OLEDB.12.0;Password="""";User ID=Admin;Data Source=" & sFULLNAME & "" _
, _
";Mode=Share Deny Write;Extended Properties="""";Jet OLEDB:System database="""";Jet OLEDB:Registry Path="""";Jet OLEDB:Database Password=""""" _
, _
";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 D" _
, "ata=False"), Destination:=.Range("$A$1")).QueryTable
.CommandType = xlCmdTable
.CommandText = Array(sQRY)
.BackgroundQuery = True
.SourceDataFile = sFULLNAME
.ListObject.DisplayName = "TABLE" & wbMACRO.Sheets.Count
.Refresh BackgroundQuery:=False