Solved

vba to relink oracle tables in msaccess 2007

Posted on 2011-09-08
7
365 Views
Last Modified: 2013-01-13
I want to use msaccess 2007 linked ODBC Oracle tables with different oracle DBs e.g. dev, uat.

e.g. original msaccess  link is to Oracle table schema1.tablex in SIDA. Access would call this schema1_tablex.

I want a script to relink schema1_tablex to e.g. schema2.tablex in SIDB. Need msaccess to still use the name schema1_tablex. As you can see, the Oracle table name stays the same, but schema and SID need to be able to be respecified when required.

I need a script, not the linked table manager in the menu.
0
Comment
Question by:graham-n
  • 2
  • 2
7 Comments
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 36507473
0
 

Author Comment

by:graham-n
ID: 36507525
the link above looks like it is for msaccess tables. Oracle tables are linked by ODBC, the do not have a path.
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 36507705
0
 
LVL 26

Accepted Solution

by:
Nick67 earned 500 total points
ID: 36512342
I am coding to paste some code in that I use for SQL Server.
The idea is the same.
The problem is that, if you are NOT using Windows Authentication, Access will NOT save the password in the connection string.
For that, you must use the GUI or delete and re-link tables.

If you have worked out the required connection strings, you should be able to transmogrify my code appropriately
Function Refresh_Table_Link()
On Error GoTo myerr
Dim TD As TableDef
Dim linkstring As String
Dim intSubStringLoc As Integer
For Each TD In CurrentDb.TableDefs
    If Len(TD.Connect) > 0 Then
        intSubStringLoc = InStr(TD.Connect, "DATABASE=YourNameHere")
        If intSubStringLoc > 0 Then
            TD.Connect = "DRIVER=SQL SERVER;SERVER=MyServer\MyInstance;DATABASE=YourNameHere;Network=DBMSSOCN;Trusted_Connection=Yes"
            TD.RefreshLink
        End If
    End If
Next

Exit Function
myerr:
MsgBox TD.Name
Resume Next

End Function

Open in new window

0
 

Author Comment

by:graham-n
ID: 36534364
I will attempt to work out a solution using parts of the replies.
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Background In several of the companies I have worked for, I noticed that corporate reporting is off loaded from the production database and done mainly on a clone database which needs to be kept up to date daily by various means, be it a logical…
Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question