
strange error linking tables
Hello--
I have a module that loops through a directory and links all .dbf tables
into an Access database. For some reason, when I attempt to add the table
to the ADOX.Catalog, I get a 'invalid argument' error. To the best of my
knowledge, this particular block of code hasn't been changed in a while, so
I'm surprised to see it not working right now. The suspect code is pasted
below, with a comment at the line that fails. Any pointers are most
appreciated.
Thanks in advance!
Damion
Private Sub SetLinkTblProperties(LinkDBFDir As String, TableName As String)
Dim cat As ADOX.Catalog
Dim tbl As ADOX.Table
If TableName = "" Then
Exit Sub
End If
On Err GoTo Err_LinkDBF
Set cat = New ADOX.Catalog
Set tbl = New ADOX.Table
'Open the catalog
cat.ActiveConnection = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &
App.Path & "\WinPos.mdb;"
'set name and target catalog for linked table
tbl.Name = TableName
Set tbl.ParentCatalog = cat
'set properties to create link
tbl.Properties("Jet OLEDB:Create Link") = True
tbl.Properties("Jet OLEDB:Cache Link Name/Password") = False
tbl.Properties("Jet OLEDB:Remote Table Name") = TableName & "#dbf"
tbl.Properties("Jet OLEDB:Link Provider String") = "dBase 5.0;HDR=NO;IMEX=2"
tbl.Properties("Jet OLEDB:Link Datasource") = LinkDBFDir
tbl.Properties("Jet OLEDB:Exclusive Link") = False
tbl.Properties("Jet OLEDB:Create Link") = True
tbl.Properties("Jet OLEDB:Table Hidden In Access") = False
'Append table to collection
cat.Tables.Append tbl '<---Failure occurs here!
Set cat = Nothing
Set tbl = Nothing
Exit Sub
Err_LinkDBF:
MsgBox ("Error linking table " & TableName & vbCrLf & _
"Error text: " & Err.Description)
Set cat = Nothing
Set tbl = Nothing
End Sub