Hello All,
I'll try to summarize the situation as best as I can.
I have an Access 2003 FE linking to an SQL 2000 BE using a DSN-Less Connection String. Both are running on my local machine for development.
I created a LinkTables method (see below), so I can select different Connection Strings for use in different locations (ie. onsite at client, at my office for development). I have no problems getting it to work on my local machine. I even took it to another office where SQL was running on a server, and the Access FE was on a workstation. The LinkMethod worked perfect.
Onsite at the client different things happen. It links fine while on ther server.
However, when I try it on a workstation, it doesn't link correctly. It says everything linked successfully, but when I try opening a table I get the error:
Connection faled :
SQLstate : '28000'
SQL Server Error : 18452
[Microsoft][ODBC SQL Server Driver][SQL Server] Login failed for user '(NULL)'.
Reason 'Not assoccated with a trusted SQL Server Connection'
Then it opens a Login box asking for a login. If I enter the correct Username and Password, all the tables open. Its almost as if the UID and PWD in the Connect String are being ignored.
Any idea's what the problem is?
Thanks.
I'll try to summarize the situation as best as I can.
I have an Access 2003 FE linking to an SQL 2000 BE using a DSN-Less Connection String. Both are running on my local machine for development.
I created a LinkTables method (see below), so I can select different Connection Strings for use in different locations (ie. onsite at client, at my office for development). I have no problems getting it to work on my local machine. I even took it to another office where SQL was running on a server, and the Access FE was on a workstation. The LinkMethod worked perfect.
Onsite at the client different things happen. It links fine while on ther server.
However, when I try it on a workstation, it doesn't link correctly. It says everything linked successfully, but when I try opening a table I get the error:
Connection faled :
SQLstate : '28000'
SQL Server Error : 18452
[Microsoft][ODBC SQL Server Driver][SQL Server] Login failed for user '(NULL)'.
Reason 'Not assoccated with a trusted SQL Server Connection'
Then it opens a Login box asking for a login. If I enter the correct Username and Password, all the tables open. Its almost as if the UID and PWD in the Connect String are being ignored.
Any idea's what the problem is?
Thanks.
Code:
Public Sub LinkTables(gLocation As String)
Dim DBPath As String
Dim td As TableDef
Dim p, i As Integer
Dim s, c, e As String
On Error GoTo Error
DBPath = Left(CurrentDb.Name, InStrRev(CurrentDb.Name, "\"))
On Error Resume Next
If gLocation = "" Then Exit Sub
c = DLookup("ConnStr", "Settings", "ID = '" & gLocation & "'")
If c = "" Then Exit Sub
On Error GoTo Error
' For Testing
c = "ODBC;DRIVER=SQL Server;UID=audituser;PWD=audituser;SERVER=CORPMAT;DATABASE=AuditTest"
i = 0
For Each td In CurrentDb.TableDefs
s = td.Connect
If Left(s, 4) = "ODBC" Then ' Check for SQL Link
td.Connect = c
td.RefreshLink
i = i + 1
End If
Next
Set td = Nothing
If e <> "" Then
MsgBox "Error Linking Tables:" & cr & e, vbExclamation
Else
MsgBox CStr(i) & " Tables Linked Successfully. Please re-open the database."
Quit
End If
leave:
Exit Sub
Error:
MsgBox "Error Linking Table! " & td.Name & cr & " Error: " & Error$, vbCritical
Resume leave
End Sub