Access 2013 SQL login error to ODBC SQL database

patrickmiller used Ask the Experts™
Wrote a program in Access 2013.  32 bit.    Had ODBC connections (System)  named MaM     connected with  sql name 'test' and pw 'testpw'.        Accessed the data on the development computer.   Windows 7 Pro.         I installed the Access 2013 runtime program on a Windows 8.1 system.     Setup the 32 bit ODBC connection with the same as above.    When I try to use the program when it accesses the data from the SQL server via the ODBC connection it fails with login failure.    It refers back to my AD login on the Window 7 computer.   I don't know what I did wrong but I really need to fix the issue because I have ten other computers to get this to work on.  Right now it works on two Windows8.1 computers.   It just stopped on this one.   Any ideas?
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®


It also says "login from untrusted domain and cannot be used with Windows Authentication"      I didn't use Windows auth.
Generally in these sorts of issues, you may have clicked the Use trusted connection option (that implies Windows Authentication).

Personally, I use a dsn-less connection - no dsn to worry about - setup one database and distribute - no connection setup needed on each machine - its ready to go.

You do need VBA to start with to do the connections.

Vitor MontalvãoIT Engineer
Distinguished Expert 2017

It's possible to post a screen shot of the ODBC configuration?
And also how are you connecting from Access?
Ensure you’re charging the right price for your IT

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!


How do I use VBA to setup the connections?
You need to create a local Access table (called ODBC connections for instance) that lists all the tables in SQL Server (TableName_SQLServer), and the name you want them to appear as in Access (TableName_Access). Then I set a constant being the connection string. Such as
Const strConnect = "ODBC;Driver={SQL Server Native Client 11.0};Server=ServerName;Database=DatabaseName;UID=UserName;PWD=password"

or if you are using SQL Server authentication

Const strConnect = "ODBC;Driver={SQL Server Native Client 11.0};Server=ServerName;Database=DatabaseName;

I ten use this code to connect - just run it once the connection string is set.

Public Function RelinkSQLTables()
On Error GoTo EH

Dim db As DAO.Database
Dim tdf As DAO.TableDef
Dim strTblServer As String
Dim strTblLocal As String
Dim rsTables As DAO.Recordset
Dim sSQL As String

Set db = CurrentDb()

sSQL = "SELECT * FROM ODBCTables where Not IsNull(TableName_SQLServer);"

Set rsTables = db.OpenRecordset(sSQL, dbOpenSnapshot)
Do Until rsTables.EOF
    For Each tdf In db.TableDefs
        If tdf.Name = rsTables!TableName_Access Then
            ''Build the dsn-less connection string
            db.TableDefs.Delete rsTables!TableName_Access
            Exit For
        End If
        Set tdf = db.CreateTableDef(rsTables!TableName_Access, dbAttachSavePWD, rsTables!TableName_SQLServer, strConnect)
        db.TableDefs.Append tdf

MsgBox "All SQL tables relinked", vbOKOnly + vbInformation, "Process Complete"

    Exit Function
    MsgBox Err.Number & ": " & Err.Description
    Resume Exit_Sub

End Function



I have never written a Public Function.    Where would I put this function for it to run?
In the modules part of the database (you are using the desktop version of Access 2013?)

In the toolbar, use the create menu and select New Module


Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial