Combo Box

A

Arvin Meyer

TSS said:
How do I add an item automatically in a combo box by using the OnNotinList
event?

How about something like this, just add some error handling (aircode):

Sub cboWhatever_NotInList(NewData As String, Response As Integer)
Dim db As DAO.Database
Dim rst As DAO.Recordset

Set db = CurrentDb
Set rst = db.OpenRecordset("tblYourTable", , dbAppendOnly)

With rst
.AddNew
!Whatever = NewData
.Update
.Close
End With

Response = acDataErrAdded

rst.Close
Set rst = Nothing
Set db = Nothing

End Sub
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads:
http://www.datastrat.com
http://www.mvps.org/access
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Combo box 0
Combo or list box 0
Combo Box On Click 8
DIALOG FORM SIZE 2
OnnotInList Event 2
OnChange and OnNotInList 1
ComboBox, OnNotinLIst and Adding additional info 14
Combo or list box 0

Top