General ODBC Error in VBA
- by raam
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