ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Microsoft Jet Error VBA Excel (https://www.excelbanter.com/excel-programming/359206-microsoft-jet-error-vba-excel.html)

[email protected]

Microsoft Jet Error VBA Excel
 
Hello,

I currently have an Excel file that uses a lot of VBA. I'm basically
using ADO to run a query. Here's the odd part, we're working on three
different computers with different versions of Excel.

1) Excel 2003 SP2 - Windows XP SP1
2) Excel 2003 - Windows XP (not sure of service Pack)
3) Excel 2002 - Windows XP SP2

Here's the thing, the file works fine on 1 & 3. However, on the Excel
2003 without SP2, it does not. I get the following error:

"Microsoft jet database engine could not find object 'MyNamedRange'"

Any ideas would be much appreciated.

Thanks in advance!


MH

Microsoft Jet Error VBA Excel
 
Post the code that is causing the problem

wrote in message
oups.com...
Hello,

I currently have an Excel file that uses a lot of VBA. I'm basically
using ADO to run a query. Here's the odd part, we're working on three
different computers with different versions of Excel.

1) Excel 2003 SP2 - Windows XP SP1
2) Excel 2003 - Windows XP (not sure of service Pack)
3) Excel 2002 - Windows XP SP2

Here's the thing, the file works fine on 1 & 3. However, on the Excel
2003 without SP2, it does not. I get the following error:

"Microsoft jet database engine could not find object 'MyNamedRange'"

Any ideas would be much appreciated.

Thanks in advance!




[email protected]

Microsoft Jet Error VBA Excel
 
Here is the code. The error happens on the "Call empRS.Open(..." line.

Dim empRS As ADODB.Recordset
Dim empSQL As String

curConnectionString = _
"Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & ThisWorkbook.FullName & ";" & _
"Extended Properties=Excel 8.0;"

Set empRS = New ADODB.Recordset
empSQL = "SELECT DISTINCT " & selColNm & ", " & selColEm & " " & _
"FROM ChartOfAccounts " & _
"WHERE ENTITY = 1;"

Call empRS.Open(empSQL, curConnectionString, adOpenForwardOnly, _
adLockReadOnly, CommandTypeEnum.adCmdText)

Do While Not empRS.EOF
msgbox empRS.Fields(1).Value
empRS.MoveNext
Loop



All times are GMT +1. The time now is 01:03 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com