Hi All,
I have a module that I call when loading forms to eliminate the need for repeatedly asking of IDs and passwords for ODBC connections. This exact same module works fantastic on over a dozen databases that I have built.
However I have one database I simply can not get this to work on. Maybe its a setting somewhere that needs to be turned on or off within Access? I just can't figure out whats wrong. The call procedure supposedly runs but I'm still asked to log in each time.
Thanks in advance... if anyone else has a good code for automating the ID and Password please feel free to share the code.l
Here is the code. Feel free to use it (I have changed the ODBC name, id and password to ficticious names).
Public Function COMNInitialize()
On Error GoTo PROC_ERR
Dim dbs As Database
Dim rs1 As Recordset
Dim rst As Recordset
Dim conn As Database
Dim strSQL As String
Dim wsODBC As Workspace
DefaultType = dbUseODBC
With DBEngine
.DefaultUser = "access"
.DefaultPassword = "iscool"
Set dbs = CurrentDb
Dim wrkRemote As Workspace
Dim strConnect As String
Dim dbsRemote As Database
strConnect = "ODBC;DSN=MMACC2010;UID=access;PWD=iscool;"
Set wrkRemote = DBEngine.Workspaces(0)
'Set dbsRemote = wrkRemote.OpenDatabase("Production", dbDriverComplete, False, strConnect)
Set dbsRemote = wrkRemote.OpenDatabase("", False, False, strConnect)
dbsRemote.Close
'Set rs1 = dbs.OpenRecordset("blanktable", dbOpenDynaset, dbSeeChanges)
End With
Exit Function
PROC_ERR:
MsgBox "The following error occured: " & Error$
'Resume Next
End Function
I have a module that I call when loading forms to eliminate the need for repeatedly asking of IDs and passwords for ODBC connections. This exact same module works fantastic on over a dozen databases that I have built.
However I have one database I simply can not get this to work on. Maybe its a setting somewhere that needs to be turned on or off within Access? I just can't figure out whats wrong. The call procedure supposedly runs but I'm still asked to log in each time.
Thanks in advance... if anyone else has a good code for automating the ID and Password please feel free to share the code.l
Here is the code. Feel free to use it (I have changed the ODBC name, id and password to ficticious names).
Public Function COMNInitialize()
On Error GoTo PROC_ERR
Dim dbs As Database
Dim rs1 As Recordset
Dim rst As Recordset
Dim conn As Database
Dim strSQL As String
Dim wsODBC As Workspace
DefaultType = dbUseODBC
With DBEngine
.DefaultUser = "access"
.DefaultPassword = "iscool"
Set dbs = CurrentDb
Dim wrkRemote As Workspace
Dim strConnect As String
Dim dbsRemote As Database
strConnect = "ODBC;DSN=MMACC2010;UID=access;PWD=iscool;"
Set wrkRemote = DBEngine.Workspaces(0)
'Set dbsRemote = wrkRemote.OpenDatabase("Production", dbDriverComplete, False, strConnect)
Set dbsRemote = wrkRemote.OpenDatabase("", False, False, strConnect)
dbsRemote.Close
'Set rs1 = dbs.OpenRecordset("blanktable", dbOpenDynaset, dbSeeChanges)
End With
Exit Function
PROC_ERR:
MsgBox "The following error occured: " & Error$
'Resume Next
End Function