Quantcast
Channel: VBForums
Viewing all articles
Browse latest Browse all 15567

[RESOLVED] Excel - Method Value of Object Range Failed

$
0
0
I've got some Excel 97 code that has worked for years.
A procedure just Errored. FWIW: I believe this is the first time this App has been run since the last Win10 update was installed.
What is most interesting is this error occurs randomly on different rows it is pulling from the Access database. I've rebuilt and compacted the Access DB and also done a fresh reboot for the computer. What is also interesting is that prior to getting the "Method Value of Object Range Failed" I was receiving an Automation error of "Method of Object Failed" until I changed from using:

With rsQuery
End With

to defining each method with just rsQuery thinking I was nested with to many With/End Withs.

Here's the code:
Code:

Private Sub ProcessFees(ByVal dtmDateBeg As Date, ByVal dtmDateEnd As Date)

  #If kDEBUGON Then
      Debug.Print "Begin ProcessFees"
  #End If

  On Error GoTo Error_ProcessFees
 
  '-----------------
 
  Dim i As Integer
  Dim rec_count As Long
 
  'Objects
  Dim rsQuery As Recordset

  '*******
  'STARTUP
  '*******
  Set rsQuery = Query_GetFees(dtmDateBeg, dtmDateEnd)
 
  If rsQuery.BOF And rsQuery.EOF Then
      Exit Sub
  Else
      rsQuery.MoveLast
      rec_count = rsQuery.RecordCount
      rsQuery.MoveFirst
  End If

  '*****
  'MAIN
  '*****
'  With rsQuery
 
      For i = 0 To (rec_count - 1)
       
        row = row + 1
       
        With oxlWB.ActiveSheet
       
            '----------
            'Set Format
            '----------
            With .Cells(row, C_BS)
                .HorizontalAlignment = xlGeneral
                .VerticalAlignment = xlBottom
                .WrapText = False
                .Orientation = 0
                .ShrinkToFit = False
                .MergeCells = False
            End With
           
            '----------
            'Enter Data
            '----------
            .Cells(row, C_BS).Value = "Fees"
            .Cells(row, C_DATE).Value = rsQuery!fldDate
           
            'NOTE Change of sign (+/-) with column change
            .Cells(row, C_TBILL_EXP).Value = rsQuery!fldFees

 
        End With
       
        'Update Running Total (WATCHOUT - changed sign for passed parameter)
        Call SetCashEquity(-rsQuery!fldFees)

        rsQuery.MoveNext
       
      Next
     
      rsQuery.Close
'  End With
 
  '*******
  'WRAPUP
  '*******
  If rec_count > 0 Then
      row = row + 1
  End If
 
  #If kDEBUGON Then
      Debug.Print "End ProcessFees"
  #End If

  Exit Sub

Error_ProcessFees:

  With TError
      .Type = ERR_CRITICAL
      .Src = mstrModule & "ProcessFees"
      .Action = MsgAndLog
  End With
 
  Call DoError

End Sub


Viewing all articles
Browse latest Browse all 15567

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>