Linked tables using ADO

G

GPO

I posted this here a few days ago. Given that there has been no response can
I assume that there is no way to link tables using ADO?
Is it possible to create a linked table in Access 2000
using ADO? I'm not keen on using docmd.transferdatabase in
case I need to use the code in something other than Access.

FWIW The table being linked to is also an MS Access table.

I can unlink them with:

Function UnlinkBackEnd(strDBToCompact As String) As Boolean
Dim cn As ADODB.Connection
Dim cat As ADOX.Catalog
Dim tbl As ADOX.Table
Dim prp As ADOX.Property

On Error GoTo ErrorHandler

Set cn = CurrentProject.Connection
Set cat = New ADOX.Catalog

cat.ActiveConnection = cn
For Each tbl In cat.Tables
For Each prp In tbl.Properties
If (prp.Name = "Jet OLEDB:Link Datasource") And _
(prp.Value = strDBToCompact) Then
Progress " Unlinking " & tbl.Name
cat.Tables.Delete tbl.Name
End If
Next
Next
UnlinkBackEnd = True
ExitHandler:
Set cn = Nothing
Set cat = Nothing
Set tbl = Nothing
Set prp = Nothing
Exit Function
ErrorHandler:
UnlinkBackEnd = False
GoTo ExitHandler
End Function

but how do I reverse the process

Cheers

GPO
 
K

Ken Snell [MVP]

Here's a few links (probably wrapped by the newsreader) to posts in other
newsgroups on similar question:

http://groups.google.com/groups?hl=...k+table+ado&hl=en&lr=&ie=UTF-8&sa=G&scoring=d


http://groups.google.com/groups?hl=...do&hl=en&lr=&ie=UTF-8&scoring=d&start=40&sa=N


You probably can find many other posts that may have the info you seek via
Google Groups
http://www.google.com/grphp?tab=ig&q=&ie=UTF-8&oe=UTF-8&hl=en


I haven't used ADO for this purpose so I cannot provide a direct answer -
sorry.
 
P

patriciaf

I code using ADO (with Access 2000), but when I need to
link Access tables I use the following DoCmd
DoCmd.TransferDatabase acLink, "\\svr002
\sites\data\appdata.mdb",
acTable, "NameTableToLink", "LinkedTableName", False

then to delete the table - I simple do a
DoCmd.DeleteObject acTable, "TableName"

**Use quotes.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top