codeliftsleep
Board Regular
- Joined
- Apr 14, 2017
- Messages
- 103
Having a very annoying problem for users which does not happen to me.
I run code when the workbook is opened that automatically connects to a SQL Server and brings back data for users depending on their role. The connections work without issue for me, but at times they throw errors for other users when trying to update a formula for a table:
Now, I know that if there is no data in the table this will throw an error, but everytime I look the data seems like it is there already when the error occurs. It almost has to be because this query runs first and then 3 additional queries run after it, which take longer to finish than this one does. The frustrating part is that it never happens when I run it, only when other people run it. The table name is valid, the column name is valid, what can be the cause of this to keep happening?
In the off chance the users are having this happen because the data hasn't finished loading for some reason, what is
I run code when the workbook is opened that automatically connects to a SQL Server and brings back data for users depending on their role. The connections work without issue for me, but at times they throw errors for other users when trying to update a formula for a table:
Code:
Private Sub CopyDailyCases(StartDate As String, EndDate As String)
Dim DailyResolved As Worksheet
Dim DailyPending As Worksheet
Dim YTDResolved As Worksheet
Dim YTDPending As Worksheet
Dim Table As ListObject
Dim Header As ListColumn
Dim iCol As Long
Set YTDResolved = Sheets("YTD Resolved Cases")
Set YTDPending = Sheets("YTD Pending Cases")
Set DailyResolved = Sheets("Resolved Cases")
Set DailyPending = Sheets("Pending Cases")
Set Table = YTDResolved.ListObjects("Table_YTDResolvedCases")
With Table
YTDResolved.AutoFilterMode = False
'On Error GoTo DoesNotExist
.ListColumns("Fixed_Report_Date").DataBodyRange.FormulaR1C1 = "=INT([SUB_QUERY_CLOSED_ON])" <---- ERROR Happens RIGHT HERE
iCol = .ListColumns("Fixed_Report_Date").Index
.Range.AutoFilter Field:=iCol, Criteria1:=">=" & CDate(StartDate), Operator:=xlAnd, Criteria2:="<=" & CDate(EndDate)
'Copy the date range
.Range.SpecialCells(xlCellTypeVisible).Copy Destination:=DailyResolved.Range("A1")
YTDResolved.ShowAllData
YTDResolved.AutoFilterMode = False
End With
Now, I know that if there is no data in the table this will throw an error, but everytime I look the data seems like it is there already when the error occurs. It almost has to be because this query runs first and then 3 additional queries run after it, which take longer to finish than this one does. The frustrating part is that it never happens when I run it, only when other people run it. The table name is valid, the column name is valid, what can be the cause of this to keep happening?
In the off chance the users are having this happen because the data hasn't finished loading for some reason, what is
Last edited: