macro does work for users after updating in in Office 365

1.5k Views Asked by At

I was converted to Office 365 2 weeks ago. After conversion, I updated a macro that runs 2 queries against an Access database. I changed the SQL to use a different date field. The 1st query runs against 2017 data while the 2nd query runs against data from prior years. The macro runs fine for me.

FYI: The reason for the different SQL statements is because the queries hit different tables for the US and Canada. The queries can also be run for a single date or a date range. The macro has worked for at least 10 years without any issues.

This macro was sent to field users in the US and Canada who are still on Office 2010. A number of them have said the macro no longer works for them. They get an error message that says Excel has stopped worked. I've remoted into a users machine and saw that the issue occurs when the 2nd query is run.

Is there something about updating a macro on Office 365 and then running it on Office 2010?

Thanks for the help.

Sub Get_Data()
    Application.ScreenUpdating = False
    Load frmDealers
    frmDealers.Show
    Startdate = CalSelDate1
    Enddate = CalSelDate2
    Dim MyGroup As String
    MyGroup = ""
    MyGroup = Cells(5, 6)
    HowMany = 0
    Got1 = False
    Got2 = False
    GotUS = False
    GotCN = False
    If Startdate <> "12:00:00 AM" And Enddate = "12:00:00 AM" Then Got1 = True
    If Startdate <> "12:00:00 AM" And Enddate <> "12:00:00 AM" Then Got2 = True
    If UCase(Mid(MyGroup, 1, 1)) = "C" Then
GotCN = True
    Else
        GotUS = True
    End If
    Dim Connection As New ADODB.Connection
    Dim RecSet1 As ADODB.Recordset
    Dim Recset2 As ADODB.Recordset
     Dim vsql As String
    Dim NoRecs1 As Boolean
    Dim NoRecs2 As Boolean
    Dim r As Integer
    Dim MyRow As Integer
    Dim MyUnit As String
    vsql = ""
    NoRecs1 = False
    NoRecs2 = False
    r = 6
    MyRow = 2
    MyUnit = ""
    Set Connection = New ADODB.Connection
    Connection.ConnectionString = ConnectionString
    Connection.Open
    Do Until Len(Trim(Cells(r, 2))) = 0
        Cells(r, 2) = UCase(Cells(r, 2))
        MyUnit = ""
        MyUnit = Cells(r, 2)
        Application.StatusBar = "Retrieving data for unit number: " & MyUnit

        If Got1 = True And GotUS = True Then
            vsql = "SELECT…….
        End If

    If Got1 = True And GotCN = True Then
            vsql = "SELECT………….
        End If

        If Got2 = True And GotUS = True Then
            vsql = "SELECT……………
        End If

        If Got2 = True And GotCN = True Then
            vsql = "SELECT…………. 
        End If
    Set RecSet1 = Connection.Execute(vsql, dbrows, adCmdText)

'       archive table
        If Got1 = True And GotUS = True Then
            vsql = "SELECT…………
        End If

        If Got1 = True And GotCN = True Then
            vsql = "SELECT…………..
        End If

        If Got2 = True And GotUS = True Then
            vsql = "SELECT…………
        End If

        If Got2 = True And GotCN = True Then
            vsql = "SELECT………… 
        End If

        '''' ERROR OCCURS on this line
        Set Recset2 = Connection.Execute(vsql, dbrows, adCmdText)

        '…other code

        NoRecs1 = False
        NoRecs2 = False
     Worksheets("Macros").Activate
        r = r + 1
    Loop

    Cells(1, 1).Select
    Connection.Close
    Set RecSet1 = Nothing
    Set Recset2 = Nothing

'''  other code to format data
    Application.ScreenUpdating = True
End Sub
0

There are 0 best solutions below