none
Resolution for the runtime error 2647 RRS feed

  • Question

  • Hi experts,

    I'm getting an error for Application.CurrentProject.Openconnection

    The connection is used to open SQL

    Is it an Office 16 issue. The application was developed in 2002 access environment while upgrading I'm getting an error.

    Regards,

    Anna


    • Edited by Anna_Smith Friday, October 27, 2017 1:24 PM
    Friday, October 27, 2017 1:22 PM

All replies

  • What is the error? Can you post your code?

    Paul ~~~~ Microsoft MVP (Visual Basic)

    • Marked as answer by Anna_Smith Friday, October 27, 2017 1:36 PM
    • Unmarked as answer by Anna_Smith Friday, October 27, 2017 1:36 PM
    Friday, October 27, 2017 1:26 PM
  • This is the Sample code

    Application.CurrentProject.Openconnection "Provider= SqlOLEDB;"&_"Data Source=" & SERVER_NM & ";"&"Initial Catalog=" & Database_name & ";"&"Integrated Security= SSPI"

    I'm getting an Runtime error 2467

    It shows The expression you entered refers to an object that is closed or doesn't exist

    How do I correct this error.

    Friday, October 27, 2017 1:46 PM
  • You have to set the connection like this:

    Dim cnn As ADODB.Connection
    
    Set cnn = CurrentProject.Connection
    cnn.ConnectionString = "Provider= SqlOLEDB;"&_"Data Source=" & SERVER_NM & ";"_
        &"Initial Catalog=" & Database_name & ";"&"Integrated Security= SSPI"
        
    cnn.ConnectionTimeout = 60
    cnn.Open
        


    Bill Mosca
    www.thatlldoit.com
    http://tech.groups.yahoo.com/group/MS_Access_Professionals

    Friday, October 27, 2017 3:14 PM
  • Thank you Bill,

    But the code did not work

    Regards

    Anna

    Friday, October 27, 2017 3:29 PM
  • Thank you Bill,

    But the code did not work

    Regards

    Anna

    I think I read somewhere that 2016 can't use the SQLOLEDB...at least for now. Try using the SQL Native Client.

    strConnect = "Driver={SQL Server Native Client 11.0};Server=SERVER_NM;Database=Database_name;" _
        & "Integrated Security=SSPI;"    


    Bill Mosca
    www.thatlldoit.com
    http://tech.groups.yahoo.com/group/MS_Access_Professionals

    Friday, October 27, 2017 4:07 PM
  • Hello Anna,

    According to CurrentProject.OpenConnection Method (Access): In the case of an Access project, the BaseConnectionString property can only specify the SQL Server OLE DB Provider.

    Does the code using Open method of ADO Connection object shared by Bill work for you?  If it doesn't work, what error do you get?

    I think the error doesn't cause from wrong connection string. Please create a new sub routine to connection data to test if the error cause from the connection string.

    Regards,

    Celeste


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, November 1, 2017 9:13 AM
    Moderator
  • My understanding is that this statement only works with an Access Data Project (.adp), which is no longer supported as of Access 2013.

    Here's some more info:

    https://stackoverflow.com/questions/27703248/how-to-set-application-currentproject-connection-in-accdb-project


    Paul ~~~~ Microsoft MVP (Visual Basic)


    Wednesday, November 1, 2017 3:19 PM
  • Thanks Paul,

    The info was really helpful

    Wednesday, December 20, 2017 10:33 AM