I am trying to create a link to a Access 2000 mde database, and connect to
one table.
The following code works fine, until I execute the "cat.Tables.Append tbl"
statement. At this point, I get know error, But the focus returns to the
form that called the function, and then I get a general protection fault
error. I have tried this with Win2K and NT 4.0 sp6.
Any help would be greatly appreciated!!
Thanks,
John
Public Function LinkToAccess(strDBName As String, strTableName As String,
strAccessTable As String)
'This function will attempt to attach/link a passed table name
' from another access db table to the current db. It will return 0 for
ok, 1 for error
LinkToAccess = 0
On Error GoTo LinkToAccess_BadLink
'Now creat the link to the database and table that were passed
Dim cat As ADOX.Catalog
Dim tbl As ADOX.Table
Set cat = New ADOX.Catalog
cat.ActiveConnection = CurrentProject.Connection
Set tbl = New ADOX.Table
tbl.Name = strAccessTable
Set tbl.ParentCatalog = cat
tbl.Properties("jet OLEDB:Create Link") = True
tbl.Properties("Jet OLEDB:Link Datasource") = strDBName
tbl.Properties("Jet OLEDB:Link Provider String") = ";pwd=wuvuth]]"
tbl.Properties("jet oledb:Remote Table Name") = strTableName
cat.Tables.Append tbl
End_LinkToAccess:
Exit Function
LinkToAccess_BadLink:
MsgBox Err.Description
LinkToAccess = 1
GoTo End_LinkToAccess
End Function