Dear Sir,
thanks for your reply for my earlier query,
What I am trying to do is i am editing RM item rate in RM master file.. my code doing it correctly, secondly i am updating bill_detail file for rate where that RM code is used in bill this also my code doing correctly, but third one where i am updating bill file for total_amt field (i.e. in bill_details, RM1, RM2, RM3 items stored and total of their rate*qty is stored in bill ) but here by codedoedn't work. My code updating only first record of bill file.
Now please look at my below code :-
If Rs.State = adStateOpen Then Rs.Close
Rs.Open "select * from product_master where sno=" & Val(LblSr.Caption), Cn, adOpenDynamic, adLockOptimistic
Rs("prod_type") = CmbType.Text
Rs("prod_sub_type") = TxtName.Text
Rs("rate") = Val(TxtRate.Text)
Rs("is_active") = Val(ChkActive.Value)
Rs.Update
Rs.Close
If Rs1.State = adStateOpen Then Rs1.Close
Rs1.Open "select * from bill_details where prod_sno=" & Val(LblSr.Caption), Cn, adOpenDynamic, adLockOptimistic
If Rs1.RecordCount > 0 Then
Rs1.MoveFirst
Dim OldRt As Integer
Dim bILL As Integer
Dim newrt As Integer
bILL = Rs1("Bill_sno")
Dim i As Integer
For i = 1 To Rs1.RecordCount
OldRt = Rs1("amt")
Rs1("rate") = Val(TxtRate.Text)
Rs1("amt") = Rs1("rate") * Rs1("qty") / 100
newrt = Rs1("amt")
Rs1.Update
up to here code is updating all records as per sql select command above, but blow line are only updating first record of bill table
If Rs2.State = adStateOpen Then Rs2.Close
Rs2.Open "Select * from bill where invoice_no =" & Rs1("Bill_sno"), Cn, adOpenDynamic, adLockOptimistic
If Rs2.RecordCount > 0 Then
Rs2.MoveFirst
Dim j As Integer
For j = 1 To Rs2.RecordCount
Rs2("total_amt") = Rs2("total_amt") - OldRt + newrt
Rs2.Update
Rs2.MoveNext
Next
Rs1.MoveNext
End If
Next
End If
Rs1.Close
Please help..
Thanks in Advance
Regards,
Software/Hardware used:
ASKED:
May 28, 2009 10:11 AM
UPDATED:
May 28, 2009 2:45 PM
Are you sure the query is returning more than one row ?
Have you tried displaying Rs2.RecordCount in a message box ?
(press the “add to discussion” button to answer)