View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
[email protected] yujie29@gmail.com is offline
external usenet poster
 
Posts: 1
Default Why this code crash Excel?

When I try to exit this program, the excel crashed.
Here is the code:

Public Sub GetLastInfo(sql$, isPre As Boolean, ByRef averCoupon, ByRef
HistCls As ClsPreLoss)
Dim m_adRst As New ADODB.Recordset
Set m_adRst = New ADODB.Recordset
On Error GoTo ERROR_HANDLER
If m_micADOConn Is Nothing Then ConnectMICDB
m_adRst.Open sql, m_micADOConn, ADODB.adOpenForwardOnly,
ADODB.adLockReadOnly
Dim averCoupon2 As Double
If isPre Then
HistCls.Pre_Bal = m_adRst.Fields("cBal")
HistCls.interest = m_adRst.Fields("nextInterest")
averCoupon = m_adRst.Fields("AverCoupon")
Else
HistCls.cBal = m_adRst.Fields("cBal")
HistCls.sBal = m_adRst.Fields("totalSched")
averCoupon2 = m_adRst.Fields("AverCoupon")
HistCls.averCoupon = (averCoupon + averCoupon2) / 2
End If
m_adRst.Close
Exit Sub
ERROR_HANDLER:
MsgBox "GetLastInfo failed: " & Err.Description
End Sub