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

Need help (operation is not allowed when the object is open)

$
0
0
i'm getting error "operation is not allowed when the object is open"

what's wrong with my codes?

Dim ASSIGN As String
Dim SQL_NUMBER As String
Dim SQL_NEW As String
Dim SQL_LIST As String
Dim SQL_FIND As String
Dim SQL_TOTAL As String

Dim RS_NUMBER As New ADODB.Recordset
Dim RS_NEW As New ADODB.Recordset
Dim RS_LIST As New ADODB.Recordset
Dim RS_TOTAL As New ADODB.Recordset
Dim RS_FIND As New ADODB.Recordset


Set RS_NUMBER = New ADODB.Recordset
Set RS_NEW = New ADODB.Recordset
Set RS_FIND = New ADODB.Recordset
Set RS_LIST = New ADODB.Recordset
Set RS_TOTAL = New ADODB.Recordset


For Each ITM In lv_IMPORT.ListItems

SQL_NUMBER = "SELECT MAX (right(MEM_NO,5)) from TBL_MEMBERS" ' GENERATE NUMBER

RS_NUMBER.Open SQL_NUMBER, CN, 3, 3

ASSIGN = "PH" + "-" + Right("00000" & IIf(IsNull(RS_NUMBER.Fields(0)), 1, RS_NUMBER.Fields(0) + 1), 6)


SQL_NEW = "SELECT * FROM TBL_MEMBERS WHERE PHILHEALTH_NO='" & ITM.SubItems(4) & "'"

RS_NEW.Open SQL_NEW, CN, 3, 3

If RS_NEW.EOF Then
RS_NEW.AddNew
RS_NEW!MEM_NO = ASSIGN
RS_NEW!LASTNAME = ITM.Text
RS_NEW!SUFFIX = ITM.SubItems(1)
RS_NEW!FIRSTNAME = ITM.SubItems(2)
RS_NEW!MIDDLE = ITM.SubItems(3)
RS_NEW!PHILHEALTH_NO = ITM.SubItems(4)
RS_NEW!SALARY = Format(ITM.SubItems(5), "#,#0")
RS_NEW.Update
End If

SQL_FIND = "SELECT * FROM TBL_MEMBERS WHERE PHILHEALTH_NO='" & ITM.SubItems(4) & "'"

RS_FIND.Open SQL_FIND, CN, 3, 3

If Not RS_FIND.EOF Then
ASSIGN = RS_FIND!MEM_NO
End If


SQL_LIST = "SELECT * FROM TBL_CONTRIBUTIONS WHERE ME5='" & StatusInfo.Panels(2) & "'" _
& " AND PHILHEALTH_NO='" & ITM.SubItems(4) & "'"


RS_LIST.Open SQL_LIST, CN, 3, 3

If RS_LIST.EOF Then
RS_LIST.AddNew
RS_LIST!MEM_NO = ASSIGN
RS_LIST!LASTNAME = ITM.Text
RS_LIST!SUFFIX = ITM.SubItems(1)
RS_LIST!FIRSTNAME = ITM.SubItems(2)
RS_LIST!MIDDLE = ITM.SubItems(3)
RS_LIST!PHILHEALTH_NO = ITM.SubItems(4)
RS_LIST!SALARY = Format(ITM.SubItems(5), "#,#0")
RS_LIST!PS = Format(ITM.SubItems(6), "#,#0")
RS_LIST!ES = Format(ITM.SubItems(7), "#,#0")
RS_LIST!C_MONTH = StatusInfo.Panels(8)
RS_LIST!C_YEAR = StatusInfo.Panels(10)
RS_LIST!ME5 = StatusInfo.Panels(2)
RS_LIST.Update
End If


Next ITM

SQL_TOTAL = "SELECT * FROM TBL_TOTALS WHERE ME5='" & StatusInfo.Panels(2) & "'"

RS_TOTAL.Open SQL_TOTAL, CN, 3, 3

If RS_TOTAL.EOF Then
RS_TOTAL.AddNew
RS_TOTAL!IMPORT_DATE = Format(Now, "MM/DD/YYYY")
RS_TOTAL!C_MONTH = StatusInfo.Panels(8)
RS_TOTAL!C_YEAR = StatusInfo.Panels(10)
RS_TOTAL!MO_YYYY = Format(StatusInfo.Panels(8), "MM") & StatusInfo.Panels(10)
RS_TOTAL!ME5 = StatusInfo.Panels(2)
RS_TOTAL!PAID_AMOUNT = Format(StatusInfo.Panels(4), "#,#0")
RS_TOTAL!RF1 = Format(StatusInfo.Panels(4), "#,#0")
RS_TOTAL!PAID_DATE = Format(StatusInfo.Panels(6), "MM/DD/YYYY")
RS_TOTAL.Update
End If

Set RS_NUMBER = Nothing
Set RS_NEW = Nothing
Set RS_FIND = Nothing
Set RS_LIST = Nothing
Set RS_TOTAL = Nothing

Viewing all articles
Browse latest Browse all 21238

Trending Articles



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