VALUE LIST Combo, <No Duplicates>

GUIDO22

Registered User.
Local time
Today, 16:00
Joined
Nov 2, 2003
Messages
515
I am using a sequence of combo boxes on a 'Continuous' form.

To reduce the possibility of error I am using a 'Value List' combo box where I use AddItem method to add the previously entered string to the combo control so that it is there for use when entering the next record.

This works fine - but what I want to ask is - does anyone have a routine to check that the string does not already exist in the combo box before I AddItem ie. I dont want duplicated values in the list.....

Thank you.
 
no, but using the instr function should work for you

if instr(combosource,newitem)=0 then
... additem
 
Scratch that request ....with a little extra effort ...... I came up with...
.... preceeded the AddItem call - with this, which seems to work fine....

Private Sub cboSpindle_AfterUpdate()
'update combo with new entry
Call AddItemToEnd(cboSpindle)

End Sub

Function AddItemToEnd(ctrl As ComboBox)
For i = 0 To ctrl.ListCount
If ctrl = ctrl.Column(i) Then
Exit Function
End If
Next i
' not found, so add it
ctrl.AddItem Item:=ctrl

End Function
 

Users who are viewing this thread

Back
Top Bottom