VB Code:
Private Sub Command1_Click()
Dim i%, sItem$, sQty%
'get new entry
sItem = Trim(txtItem.Text)
sQty = Val(Trim(txtQty.Text)) 'not the best way but it works to some extent
With Form2.List1
'check if item already exit
If .ListCount > 0 Then
For i = 0 To .ListCount - 1
If InStr(1, .List(i), sItem) > 0 Then
'it does - change it
.List(i) = sItem & " (" & txtQty.Text & ")"
Exit Sub
End If
Next i
End If
'it doesn't - add new
.AddItem sItem & " (" & txtQty.Text & ")"
End With
End Sub
Private Sub txtItem_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then Command1_Click
End Sub
Private Sub txtQty_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then Command1_Click
End Sub