DBL
09-04-2008, 02:22 AM
I have a multi column list box where I want the user to select the items that they want and for the selected items to be inserted into a table. This is the code I'm using:
For i = 0 To List3.ListCount - 1
If Me.List3.Selected(i) = True Then
CurrentDb.Execute "INSERT INTO tblOrderDetails (ODJobID, ODItemNo, ODQty, ODPrice, ODDesc,ODDrawingNo) VALUES (" & Me.Text8 & ", " & Me.List3.ItemData(i) & "," & Me.List3.Column(2) & ", " & Me.List3.Column(3) & ", '" & Me.List3.Column(4) & "','" & IIf(IsNull(Me.List3.Column(5)), "", Me.List3.Column(5)) & "')"
End If
Next i
If there are 2 items select from the list it will insert 2 rows into the table but it's the same 2 rows, ie:
Item No Quantity Description Drawing No (+) Unit Price Line Total Req Del Date Act Del Date Entered Entered By
4 1 Test quote 2 item 2 175 £175.00 04/09/08
4 1 Test quote 2 item 2 175 £175.00 04/09/08
For i = 0 To List3.ListCount - 1
If Me.List3.Selected(i) = True Then
CurrentDb.Execute "INSERT INTO tblOrderDetails (ODJobID, ODItemNo, ODQty, ODPrice, ODDesc,ODDrawingNo) VALUES (" & Me.Text8 & ", " & Me.List3.ItemData(i) & "," & Me.List3.Column(2) & ", " & Me.List3.Column(3) & ", '" & Me.List3.Column(4) & "','" & IIf(IsNull(Me.List3.Column(5)), "", Me.List3.Column(5)) & "')"
End If
Next i
If there are 2 items select from the list it will insert 2 rows into the table but it's the same 2 rows, ie:
Item No Quantity Description Drawing No (+) Unit Price Line Total Req Del Date Act Del Date Entered Entered By
4 1 Test quote 2 item 2 175 £175.00 04/09/08
4 1 Test quote 2 item 2 175 £175.00 04/09/08