Combo Box - Add values as per data entry (1 Viewer)

Valery

Registered User.
Local time
Today, 08:16
Joined
Jun 22, 2013
Messages
363
Hi all ! I think I found the coding I need on this site. But I would not know how to adapt it.

I would like an auto text completion combo box that will save NEW data entry so it can be used in the following records.

This is what I found. If this coding is correct, can you please identify for me the sections where I need to make changes and what they are (name of control, name of combo box...)? Also, please confirm where to enter these codes. In a module?

Code:
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

THANK YOU Kindly.
 

Ranman256

Well-known member
Local time
Today, 11:16
Joined
Apr 9, 2015
Messages
4,337
You don't really add data to a combo box, you add it to the table where the data comes from.
If the user enters an item not on the list , just run an append query to add it to the source table. No code needed. ( well, just the query cmd.)

Sub cboBox_afterupdate
Docmd.setwarnings false
Docmd.openquery "qaAddCboItem"
End sub
 

Users who are viewing this thread

Top Bottom