JRinderer
New Member
- Joined
- Dec 1, 2015
- Messages
- 17
Hello all, I've spent the past few hours combing the net trying to find a possible solution. I have a program that populates an Excel sheet from an Access table. The issue I'm having is that everyone in the office on 2010 is able to run this without any problems; but a user with 2016 is having them. I've verified the file is correct (not on an older version); verified she's connected to the appropriate network.
I'm getting an Run Time Error 91 Object Variable or With Block Variable not Set on this line of code (I have the entire section included as well:
Set rst = .currentDb.OpenRecordset("SELECT " & sqlString & " FROM SomeTable WHERE " & whereCaluse)
For the life of me... I can't figure it out. I've tried to do some research on if something between 2016 and 2010 changed that could cause this but she just started reporting this issue.
As a side note I don't get the option to Debug, a message box pops up that says "Ok" and "Help".
My References are:
Visual Basic For Applications
Microsoft Excel 14.0 Object Library
OLE Automation
Microsoft Office 14.0 Object Library
Accessibility CplAdmin 1.0 Type Library
Microsoft Data Access Components Installed Version
Microsoft Access 14.0 Object Library
Microsoft ActiveX Data Objects 2.0 Library
Microsoft Forms 2.0 Object Library
Microsoft DAO 3.6Library
I've attempted to move DAO reference; but that didn't appear to work either.
I'm thinking it's possibly:
1. Reference Error
2. Error in the Code --Perhaps I didn't set an object I declared? But would that all the sudden have caused this to stop?--
3. Perhaps there's an update in 2016 that could be causing this.
Typically this error indicates I haven't ended a With Statement, or Set a variable. But as you can see Set is clearly in the line it errors out on. I cannot replicate this error on my own machine. I've requested a second computer with 2016 Office to test this out.
I seem to have followed all the necessary rules; but the computer is very rarely wrong. I have to be missing something.
I'm getting an Run Time Error 91 Object Variable or With Block Variable not Set on this line of code (I have the entire section included as well:
Set rst = .currentDb.OpenRecordset("SELECT " & sqlString & " FROM SomeTable WHERE " & whereCaluse)
For the life of me... I can't figure it out. I've tried to do some research on if something between 2016 and 2010 changed that could cause this but she just started reporting this issue.
Code:
Dim wrkBk As Workbook
Dim wrkSht As Worksheet
'ThisWorkbook.Sheets("WorkSheet").Columns(1).Find("*", , , , xlByColumns, xlPrevious).Row
With Application
.ScreenUpdating = False
End With
WasWrkBookOpen
'ThisWorkbook.RefreshAll
Set wrkBk = ThisWorkbook
Set wrkSht = wrkBk.Sheets("Tracker")
'MsgBox (valsFromBttn)
wrkSht.Columns("A:BAZ").EntireColumn.Hidden = False
wrkSht.Cells.AutoFilter
wrkSht.Cells.ClearContents
ThisWorkbook.Sheets("Data-Original").Cells.ClearContents
'MsgBox (sqlString)
Dim appAcc As New Access.Application
Dim rst As DAO.Recordset
Dim i As Long
Const path As String = "\SomeLocation\AccessDatabaseFile"
If sqlString = "" Then
MsgBox ("Please note it looks like you haven't select a team. You will be given the full default view. If you believe you've reached this message in error contact John Rinderer")
sqlString = "*"
whereCaluse = "[Site Num] <> 'TEST1'"
End If
'[Site Num] <> 'TEST1' AND (Market = 'AROK' or Market = 'COLORADO' or Market = 'S.TX' or Market = 'UnAssigned-Ter')")
With appAcc
.OpenCurrentDatabase path
Set rst = .currentDb.OpenRecordset("SELECT " & sqlString & " FROM LaunchPadDb WHERE " & whereCaluse) '****THIS IS WHERE WE ERROR OUT*******
For i = 1 To rst.Fields.Count - 1
Sheet9.Cells(1, i + 1).value = rst.Fields(i).Name
Next i
Sheet9.Range("A2").CopyFromRecordset rst
End With
Set rst = Nothing
appAcc.CloseCurrentDatabase
Set appAcc = Nothing
As a side note I don't get the option to Debug, a message box pops up that says "Ok" and "Help".
My References are:
Visual Basic For Applications
Microsoft Excel 14.0 Object Library
OLE Automation
Microsoft Office 14.0 Object Library
Accessibility CplAdmin 1.0 Type Library
Microsoft Data Access Components Installed Version
Microsoft Access 14.0 Object Library
Microsoft ActiveX Data Objects 2.0 Library
Microsoft Forms 2.0 Object Library
Microsoft DAO 3.6Library
I've attempted to move DAO reference; but that didn't appear to work either.
I'm thinking it's possibly:
1. Reference Error
2. Error in the Code --Perhaps I didn't set an object I declared? But would that all the sudden have caused this to stop?--
3. Perhaps there's an update in 2016 that could be causing this.
Typically this error indicates I haven't ended a With Statement, or Set a variable. But as you can see Set is clearly in the line it errors out on. I cannot replicate this error on my own machine. I've requested a second computer with 2016 Office to test this out.
I seem to have followed all the necessary rules; but the computer is very rarely wrong. I have to be missing something.