Link to home
Start Free TrialLog in
Avatar of route217
route217Flag for United Kingdom of Great Britain and Northern Ireland

asked on

Unable to connect sql to ms access....

Hi Experts
(this is a follow up question to: https://www.experts-exchange.com/questions/28232414/Pass-through-qry-Part-2.html)

And once again sorry/apologies if this is not the correct method of posting questions on the EE board. Sorry!!! if i have borken any rules.


I am having a nightmare trying to establish a connection to ms access via sql on a odbcad32.exc...

i have tried using the following vba to change the connection string and no luck for two days...

Public Function GetQueryLinks()
On Error GoTo Err_GetQueryLinks

    'Dim StrConn As ADODB.Connection
    'Set StrConn = New ADODB.Connection
    
    Dim qdf As DAO.QueryDef
    Dim StrConn As String
    
     StrConn = "ODBC;Driver=(Apples_Oranges);SERVER=SQAAPB3SBCA65130.global.Hire.com;Database=Apples_Oranges);;Port=12351;"
    
     
     For Each qdf In CurrentDb.QueryDefs
        If qdf.Connect <> "" Then

            qdf.Connect = StrConn
            Debug.Print qdf.Connect

        End If

        Next
            
Exit_GetQueryLinks:
    Set qdf = Nothing
    Exit Function

Err_GetQueryLinks:
    MsgBox Err.Number & " (" & Err.Description & ") in procedure GetQueryLinks of Module basTableLinks"
    Resume Exit_GetQueryLinks

End Function

Open in new window

Avatar of Zberteoc
Zberteoc
Flag of Canada image

Avatar of route217

ASKER

thanks for the feedback..

what about the other way around access to sql..
ASKER CERTIFIED SOLUTION
Avatar of Zberteoc
Zberteoc
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
hi expert...
thanks for the feedback but this is connecting sql to access...whats the reverse cod2...

I am  new to this...how do u connect access to sql...my initial vba is attached. .
My second message gives links about how to connect to SQL server, from any application, Access included.