uncool
uncool

Reputation: 2703

Adding connection to workbook - Invalid procedure call or argument Run time error 5

I'm trying to make a Tablecollection import from my access data. Been trying for a while with the connections.add2 method but vba keeps giving me the same error message.

My tables in my access database are as follows : ALFA, ERIC, GETI, HM, Instruments, YHOO

The connection-string is correct. So what can be wrong?

Error message: "Invalid procedure call or argument" Run time error 5

Code

Dim ConnString As String: ConnString = "Provider=Microsoft.ACE.OLEDB.12.0;User ID=Admin;Data Source=C:\Users\name\Desktop\DataBase.accdb;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 Data=False;Jet OLEDB:Bypass UserInfo Validation=False;Jet OLEDB:Limited DB Caching=False;Jet OLEDB:Bypass ChoiceField Validation=False"

Workbooks("YQL.xlsm").Connections.Add2 _
    "DataBase2", _
    "", _
    ConnString, _
    "'ALFA','ERIC','GETI','HM','Instruments','YHOO", _
    xlCmdTableCollection, _
    True, _
    True

Upvotes: 0

Views: 796

Answers (1)

Dane I
Dane I

Reputation: 742

You're missing an apostrophe after YHOO. Does this fix your issue?

Upvotes: 2

Related Questions