General ODBC Error in VBA

Posted by raam on Stack Overflow See other posts from Stack Overflow or by raam
Published on 2010-06-09T07:51:16Z Indexed on 2010/06/09 8:22 UTC
Read the original article Hit count: 432

Filed under:
|

Hi am populating the data from MS Access By Using VBA i am using below mentioned code.if i am run the same code in MS 2007 then It run properly but if i am run the same code in MS 2003 it gives the "General ODBC Error" how to solve this problem Any help would be appreciated!!

Thanks in advance

Sub Button2_Click()
Dim varConnection As String
Dim varSQL As String
Dim cal, cal1, x

 varConnection = "ODBC; DSN=MS Access Database;DBQ=D:\Box\Generate.mdb;Driver={Driver do Microsoft Access (*.mdb)}"
'
       varSQL = "SELECT * FROM Empdata"

       With ActiveSheet.QueryTables.Add(Connection:=varConnection, Destination:=ActiveSheet.Range("C7"))

               .CommandText = varSQL

               .Name = "Query-39008"

               .Refresh BackgroundQuery = False
       End With



End Sub

© Stack Overflow or respective owner

Related posts about vba

Related posts about access-vba