Finally gave up and putting it here.
I am new to visual basic stucked up with an error-
Run time errors.'-2147217887 (8004021)': Multiple-step operation generated errors. check each status value.
Error comes at ADODC.RECORDSET.UPDATE command.
Because of multi column listbox's limitations I'm using 3 istboxes which temporarily save items to be sold and at last get updated into database on a command button click event.
Also I am using some temporary variables and textboxes to store data because Addnew command clears the fields.
Interesting things
1. It saves successfully for first two attempts and at third time it shows me above error.
2. Even if the conditions are satisfied for FOR loop it gets out of the loop after a run.
here is detail
Expand|Select|Wrap|Line Numbers
- If NoSale = True Then
- Exit Sub
- Else
- 'SHOWS A DIALOG SETS THE VALUE OF DebitCredit.Text
- DialogDbCr.Show
- If DebitCredit.Text = "" Then
- Exit Sub
- Else
- If DebitCredit.Text = "CREDIT" Then
- OtherCash.Text = "CREDIT"
- 'IF SALE IS ON CREDIT NO NEED OF CASH DETAIL
- Else
- If DebitCredit.Text = "DEBIT" Then DialogCash.Show
- 'DialogCash SETS THE DETAIL OF CASH INTO OtherCash.Text
- End If
- If OtherCash.Text = "" Then
- Exit Sub
- Else
- 'SOME TEMP VARIABLES AND TEXT BOXES ARE STORING VALUES
- CashOther = OtherCash.Text
- DebCre = DebitCredit.Text
- 'TempState.Text = OtherMP.Text
- TempDate.Text = SDate.Text
- Dis = Val(DiscountGiven.Text)
- tx = Val(Tax.Text)
- 'TIME TO UPDATE
- ' LCount IS LISTCOUNT (NUMBER OF LIST ITEMS)
- For i = 0 To i = LCount - 1
- SaleData.Refresh '''''''''''''ADODC.REFRESH
- SaleData.Recordset.AddNew
- 'RESTORING DATA TO DATA BOUND CONTROLS FROM TEMP VARIABLES 'AND TEXT BOXES
- 'HID_Sale AND CID_Sale ARE TEXTBOXES
- HID_Sale = Val(HCompanyID.Text)
- CID_Sale = Val(CustomerID.Text) '''''
- OtherMP.Text = TempState.Text
- SDate.Text = TempDate.Text
- 'OtherCash AND DebitCredit ARE TEXTBOXES
- 'CashOther and DebCre ARE VARIABLES AS STRING
- OtherCash = CashOther
- DebitCredit = DebCre
- ' Tax AND DiscountGiven ARE TEXT BOXES
- 'Dis AND tx ARE VARIABLE AS DOUBLE
- DiscountGiven = Dis '
- Tax = tx
- 'TEXT BOXES RESTORING DATA FROM LIST BOXES
- PID_Sale = Val(ProIDList.List(i))
- Quantity = Val(QuaList.List(i)) '''''
- SPrice = Val(RateList.List(i))
- TotalAmount = Val((Val(Val(Val(SPrice.Text) * Val(Quantity.Text)) * Val(Tax.Text)) / 100) + Val(Val(SPrice.Text) * Val(Quantity.Text)) - Val(Val((Val(Val(Quantity.Text) * Val(SPrice.Text)) * Val(DiscountGiven.Text))) / 100))
- SaleData.Recordset.Update ' ERRORRRRRRRRRR
- 'SaleData.Refresh
- Next i
- MsgBox "Sold"
- SaleData.Refresh
- Call Clear
- Call EnableSale
- Call EnableControls
- ProIDList.Clear
- QuaList.Clear
- RateList.Clear
Please point out my mistakes and help me.
NE☼