How to: Take over the links a front end already has
Start using the link manager in a front end whose tables were linked by hand or by older code, without typing the configuration.
Requires WKL Forms Object Library 1.23 or later.
Solution overview
ImportLinks reads the front end's ODBC links that the configuration doesn't list yet and writes
them to USysConnection and USysLinkedTable: one connection row per source and one table row per
link. In the designer, this is Take over existing on the Check and synchronize page.
Afterward, Check reports no differences, and the first EnsureLinks changes nothing.
Implementation
In the designer, open Database Tools › Add-Ins › WKL Linked Tables Manager, go to the Check and synchronize page, choose the profile the links belong to, and click Take over existing.
In VBA:
Public Sub TakeOverLinks()
Dim links As New WklLinkManager
Debug.Print links.ImportLinks("PROD") & " links taken over"
Debug.Print links.Check("PROD").Count & " differences" ' 0
End Sub
Then give the connection rows meaningful names on the Connections page, and add the other profiles (Profiles page, Copy profile …).
Remarks
- Only ODBC links are taken over; links to Access databases, Excel files, or SharePoint lists are left as they are.
- New connection rows get the profile passed to
ImportLinks, or otherwise theEnvironmentproperty; with neither, they serve every profile. - A password stored in a link is written to
Parameterin clear text, as the link held it. Remove it there if the front end shouldn't store it (How to: Choose how linked tables log in). - Links that the configuration already lists aren't changed; run
Checkto see whether they match.