Hi
I recorded a macro that should connect a table in my workbook to different Access databases. I changed some of the code so that it finds the filepath in a cell in one of the worksheets. The code works fine on meny different Access databases. But not on others. I can't figure out why...
Range("Tabell_Database_1[[#Headers],[ID]]").Select With ActiveWorkbook.Connections(1).OLEDBConnection .BackgroundQuery = True .CommandText = Array("Resultater") .CommandType = xlCmdTable .Connection = Array( _ "OLEDB;Provider=Microsoft.ACE.OLEDB.12.0;Password="""";User ID=Admin;Data Source=" & Worksheets("Samlet").Range("O1") & ";Mode=Share Deny Write;Extended Properties="""";Jet OLEDB:System database="""";Jet OLE" _ , _ "DB:Registry Path="""";Jet OLEDB:Database Password="""";Jet OLEDB:Engine Type=6;Jet OLEDB:Database Locking Mode=0;Jet OLEDB:Global Pa" _ , _ "rtial 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" _ ) .RefreshOnFileOpen = False .SavePassword = False .SourceConnectionFile = "" .SourceDataFile = Worksheets("Samlet").Range("O1") .ServerCredentialsMethod = xlCredentialsMethodIntegrated .AlwaysUseConnectionFile = False End With With ActiveWorkbook.Connections(1) .Name = Worksheets("Samlet").Range("O2").Text .Description = "" End With ActiveWorkbook.Connections(1).Refresh
Bookmarks