Hello everyone good day!
I have this problem in my program.
Situation: I have ListBox that contains all Bottle Number, which is a Primary Key of my Table: Bottles. What I want to do is update all rows in the table Bottles where bottle number = ListAssigned.Li stIndex = i. Here is my code: (I've used FOR LOOP to loop in all the entries in my Listbox).
[CODE=vb]Private Function UpdateBottles()
Dim i As Integer
For i = 0 To ListAssigned.Li stCount - 1
With rsbot2
.ActiveConnecti on = cn
.CursorLocation = adUseClient
.CursorType = adOpenKeyset
.LockType = adLockOptimisti c
.Open "SELECT * FROM bottles WHERE bot_number =" & Val(ListAssigne d.ListIndex = i)
End With
Call assignBot
With rsbot2
.Update
.Requery
.UpdateBatch
End With
rsbot2.Close
Next i
End Function
Private Sub assignBot()
rsbot2(0) = Val(cmboBotNo.T ext)
rsbot2(1) = "Borrowed"
rsbot2(3) = Val(lblDumOrder Id.Caption)
rsbot2(4) = Val(lblDumID.Ca ption)
End Sub[/CODE]
This code is not working. It didn't update any row in the table. I need help on this.
Thanks and God bless
DaveftL
I have this problem in my program.
Situation: I have ListBox that contains all Bottle Number, which is a Primary Key of my Table: Bottles. What I want to do is update all rows in the table Bottles where bottle number = ListAssigned.Li stIndex = i. Here is my code: (I've used FOR LOOP to loop in all the entries in my Listbox).
[CODE=vb]Private Function UpdateBottles()
Dim i As Integer
For i = 0 To ListAssigned.Li stCount - 1
With rsbot2
.ActiveConnecti on = cn
.CursorLocation = adUseClient
.CursorType = adOpenKeyset
.LockType = adLockOptimisti c
.Open "SELECT * FROM bottles WHERE bot_number =" & Val(ListAssigne d.ListIndex = i)
End With
Call assignBot
With rsbot2
.Update
.Requery
.UpdateBatch
End With
rsbot2.Close
Next i
End Function
Private Sub assignBot()
rsbot2(0) = Val(cmboBotNo.T ext)
rsbot2(1) = "Borrowed"
rsbot2(3) = Val(lblDumOrder Id.Caption)
rsbot2(4) = Val(lblDumID.Ca ption)
End Sub[/CODE]
This code is not working. It didn't update any row in the table. I need help on this.
Thanks and God bless
DaveftL
Comment