Solved

vba to relink oracle tables in msaccess 2007

Posted on 2011-09-08
7
367 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

733 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