Can someone please help me create code that when called it create an ODDC connection with an Oracle driver in an Access database. I have code that will connect but i really need one that will create it when called.
Function OracleConnect() As Boolean
Dim ws As Workspace
Dim db As Database
Dim LConnect As String
On Error GoTo Err_Execute
'Use {Microsoft ODBC for Oracle} ODBC connection
'CreateWorkspace
LConnect = "ODBC;DSN=LAHP1;UID=XXX;PWD=XXXX;SERVER=dclahop0"
'Point to the current workspace
Set ws = DBEngine.Workspaces(0)
'Connect to Oracle
Set db = ws.OpenDatabase("", False, True, LConnect)
db.Close
OracleConnect = True
Exit Function
Err_Execute:
MsgBox "Connecting to Oracle failed."
OracleConnect = False
End Function
Function OracleConnect() As Boolean
Dim ws As Workspace
Dim db As Database
Dim LConnect As String
On Error GoTo Err_Execute
'Use {Microsoft ODBC for Oracle} ODBC connection
'CreateWorkspace
LConnect = "ODBC;DSN=LAHP1;UID=XXX;PWD=XXXX;SERVER=dclahop0"
'Point to the current workspace
Set ws = DBEngine.Workspaces(0)
'Connect to Oracle
Set db = ws.OpenDatabase("", False, True, LConnect)
db.Close
OracleConnect = True
Exit Function
Err_Execute:
MsgBox "Connecting to Oracle failed."
OracleConnect = False
End Function