simple automated id and password module not working

KirkComer

Registered User.
Local time
Today, 17:59
Joined
Oct 21, 2005
Messages
50
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
 
Okay. I figured out what was wrong. I was working in a data base that someone else had created. They linked tables a different way than I did. Their connection looked line this in the linked table manager. C:\\WINDOWS\ODBC\Data Sources\{Library Name}.dsn

I simply relinked all the tables and they reflected the ODBC connection as I am accustomed to seeing it (which is how I have it in the code). Hope this makes sense and thanks to all that took a look at my problem.
 

Users who are viewing this thread

Back
Top Bottom