How does one attach an Oracle table in MS-Access?
Submitted by admin on Wed, 2005-11-09 13:50.
Create a linked table under the table tab in Access. Right click; select link table. A dialog box opens, at the bottom, change the "files of type" box to ODBC Databases. This will open the Data Source dialog box. Select your data source, file or machine (note the type you created earlier). You will now be prompted to login to the Oracle database.
One can also link a table programmatically. Open a new MODULE in Access, add this code to it and RUN (F5):
Option Compare Database
Option Explicit
Function AttachTable() As Variant
On Error GoTo AttachTable_Err
Dim db As Database
Dim tdef As TableDef
Dim strConnect As String
Set db = CurrentDb()
strConnect = "ODBC;DSN=oraweb;DBQ=qit-uq-cbiw_oraweb;DATABASE="
' NOTE: DSN is your ODBC Data Source Name; DBQ is your TNSNAMES.ORA entry name
Set tdef = db.CreateTableDef("MY_ACCESS_TABLENAME")
' tdef.Attributes DB_ATTACHEDODBC
tdef.Connect = strConnect
tdef.SourceTableName = "MY_ORACLE_TABLENAME"
db.TableDefs.Append tdef
AttachTable_Exit:
Exit Function
AttachTable_Err:
MsgBox "Error: " & Str(Err) & " - " & Error$ & " occured in global module."
Resume AttachTable_Exit
End Function»
- Login to post comments

