Quantcast
Channel: VBForums - Visual Basic 6 and Earlier
Viewing all articles
Browse latest Browse all 21847

operation is not allowed when the connection is closed

$
0
0
I'm having trouble in my discount computation for about a day now and I have to finish my system tomorrow please help me
Code:

Dim a As Double
Dim b As String
Dim Desc As String


Private Sub cbdiscount_Click()
OpenCon
Set rs = New ADODB.Recordset
        rs.Open "Select * From [discount] where [Description] = '" & cbdiscount.text & "'", con, adOpenStatic, adLockOptimistic
          If rs.RecordCount <> 0 Then
          a = rs![Amount]
          b = rs![Percent]
          Desc = rs![Description]
          End If
        rs.Close
        con.Close
       
If cbdiscount.Text = "First Honor" Then
        OpenCon
        Set rs = New ADODB.Recordset
            rs.Open "Select * From [fees] where [yearlevel]='" & frmassesment.txtstudlvl.Text & "'", con, adOpenStatic, adLockOptimistic
               
                For x = 1 To rs.RecordCount
                    frmassesment.lblmisc.Caption = rs![miscfees]
                    frmassesment.lblothers.Caption = rs![others]
                    frmassesment.totaltuition.Caption = rs![total]
                    frmassesment.lbltuition.Caption = rs![tuitionfees]
            rs.MoveNext
                Next x

    If a = 100 Then
            lbltuition.Caption = (Val(lbltuition.Caption) * 1)
            totaltuition.Caption = (Val(lblothers.Caption)) + (Val(lblmisc.Caption))
           
ElseIf cbdiscount.Text = "Second Honor" Then
            lbltuition.Caption = (Val(lbltuition.Caption) / 0.5)
            totaltuition.Caption = (Val(totaltuition.Caption)) + (Val(lblothers.Caption)) + (Val(lblmisc.Caption))
rs.Close
con.Close
End If
End If

error appears in rs.close

Viewing all articles
Browse latest Browse all 21847

Trending Articles



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