Results 1 to 5 of 5
  1. #1
    jaryszek is offline Expert
    Windows 7 32bit Access 2010 32bit
    Join Date
    Aug 2016
    Posts
    568

    Accessing SQL Server Via ODBC

    Hi, i have linked tables from Access FE to MS SQL BE using ODBC connection.



    Problem is that every time if i am opening my FE i have to write the password again:

    Click image for larger version. 

Name:	Przechwytywanie.jpg 
Views:	14 
Size:	88.2 KB 
ID:	32179

    Is the way to save the password only once?


    Thank you,
    Jacek

  2. #2
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,954
    Try this function.
    It covers a wide variety of connection types:

    Code:
    '############################################
    ' GetConnectionString 04/08/2010 
    '   Used to create a connection string
    '############################################
    Function GetConnectionString(strLinkType, _
                                strLinkServer, _
                                strLinkDatabase, _
    			    strAppName, _	
                                strLinkUsername, _
                                strLinkPassword) As String
            
        Select Case strLinkType 'Get the link type to determine the connection string
    #If SQL_DRIVER = "Native" Then
            Case "SQL"
                GetConnectionString = "ODBC;DRIVER={SQL Native Client};" & _
                                        "SERVER=" & Nz(strLinkServer, "") & ";" & _
                                        "DATABASE=" & Nz(strLinkDatabase, "") & ";" & _
                                        "APP=strAppName;" & _
                                        "UID=" & Nz(strLinkUsername, "") & ";" & _
                                        "PWD=" & Nz(strLinkPassword, "")
            Case "SQL-Trusted"
                GetConnectionString = "ODBC;DRIVER={SQL Native Client};" & _
                                        "SERVER=" & Nz(strLinkServer, "") & ";" & _
                                        "DATABASE=" & Nz(strLinkDatabase, "") & ";" & _
                                        "APP=strAppName;" & _
                                        "Trusted_Connection=yes;"
    #ElseIf SQL_DRIVER = "MDAC" Then
            Case "SQL"
                GetConnectionString = "ODBC;DRIVER={SQL Server};" & _
                                        "SERVER=" & Nz(strLinkServer, "") & ";" & _
                                        "DATABASE=" & Nz(strLinkDatabase, "") & ";" & _
                                        "APP=strAppName;" & _
                                        "UID=" & Nz(strLinkUsername, "") & ";" & _
                                        "PWD=" & Nz(strLinkPassword, "")
            Case "SQL-Trusted"
                GetConnectionString = "ODBC;DRIVER={SQL Server};" & _
                                        "SERVER=" & Nz(strLinkServer, "") & ";" & _
                                        "DATABASE=" & Nz(strLinkDatabase, "") & ";" & _
                                        "APP=strAppName;" & _
                                        "Trusted_Connection=yes;" & _
                                        ""
    #End If
            Case "Access"
                If Nz(strLinkPassword, "") <> "" Then
                    GetConnectionString = "MS Access;" & _
                                        "PWD=" & Nz(strLinkPassword, "") & ";" & _
                                        "DATABASE=" & Nz(strLinkServer, "") & Nz(strLinkDatabase, "")
                Else
                    GetConnectionString = "MS Access;" & _
                                        "DATABASE=" & Nz(strLinkServer, "") & Nz(strLinkDatabase, "")
                End If
            Case Else
                GetConnectionString = ""
        End Select
    
    
    End Function
    HTH
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  3. #3
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    FYI, when you manually link the tables there is a checkbox that will allow you to save the password. It should never ask again.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  4. #4
    jaryszek is offline Expert
    Windows 7 32bit Access 2010 32bit
    Join Date
    Aug 2016
    Posts
    568
    Thank you Guys !

    pbaldy you hit the point ! It is working

    Jacek

  5. #5
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    Happy to help!
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 3
    Last Post: 12-12-2017, 11:34 AM
  2. Replies: 1
    Last Post: 08-08-2016, 04:42 PM
  3. SQL Server, ODBC, DSN, Access
    By cbende2 in forum Access
    Replies: 10
    Last Post: 06-23-2015, 01:12 PM
  4. Connection to SQL Server ODBC Failed
    By Historypaul in forum SQL Server
    Replies: 2
    Last Post: 01-05-2015, 01:50 PM
  5. Access security ODBC to SQL Server
    By Mark@CHP in forum Security
    Replies: 3
    Last Post: 03-27-2012, 08:31 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums