Solved

vba to relink oracle tables in msaccess 2007

Posted on 2011-09-08
7
370 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

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

AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
This video explains what a user managed backup is and shows how to take one, providing a couple of simple example scripts.
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

691 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