I have a database running on SQL Server8. There are several users that connect to the database through ODBC using laptops that are running Windows XP. Everything works well for them.
New laptops with Windows 7 have a connection issue. When connecting with a Widnows 7 PC the following code is receiving the ERROR message 3151 on the OpenRecordset command. The ODBC is setup to have a user entered name and password. When testing the ODBC connection it connects successfully.
[VBA]Private Sub Form_Open(Cancel As Integer)
Dim Connection_flag As String
Dim rstdb As xRecordset
On Error GoTo Form_Open_Err
Set db = CurrentDb()
Connection_flag = "N"
DoCmd.Echo True, "Connecting to SQL Server...."
Set rstdb = db.OpenRecordset("Login", dbOpenDynaset)
Connection_flag = "Y"
' Maximize form
DoCmd.Maximize
DoCmd.ShowToolbar "CSRData toolbar"
Form_Open_Exit:
Exit Sub
Form_Open_Err:
If Err.Number = 3059 And Connection_flag = "N" Or Err.Number = 3151 And Connection_flag = "N" Or Err.Number = 3146 And Connection_flag = "N" Then
MsgBox "Login incorrect!!!" _
, vbOKOnly, "SQL Server Login Error"
DoCmd.Echo True, "Shutting down application...."
DoCmd.Quit
Else
MsgBox Error$
Resume Form_Open_Exit
End If
End Sub[/VBA]