Combo Box

  • Thread starter Thread starter Guest
  • Start date Start date
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
 
Back
Top