Combobox default lit & add new

  • Thread starter Thread starter Saintsman
  • Start date Start date
S

Saintsman

Hi
Is it possible to have a default list in a combobox & also allow users to
add new items?
In a new application I want to set up a series of typical text responses for
a drop down, but also let the list grow as new responses are added by users

Thanks
Saintsman
 
Saintsman said:
Hi
Is it possible to have a default list in a combobox & also allow users to
add new items?
In a new application I want to set up a series of typical text responses
for
a drop down, but also let the list grow as new responses are added by
users

Thanks
Saintsman

Yes, you use a lookup table as the combo's row source and use the "on not in
list" event to add the new value to the lookup table. Below is an example
of code, hope it helps.

Keith.
www.keithwilby.co.uk

Private Sub cboManagerName_NotInList(NewData As String, Response As Integer)

DoCmd.Hourglass True
Dim strAlias As String
Dim db As DAO.Database, rs As DAO.Recordset, strSQL As String
Set db = CurrentDb
strSQL = "Select ManagerName from qcboManager"
Set rs = db.OpenRecordset(strSQL)
With rs
.AddNew
![ManagerName] = strAlias
.Update
End With
rs.Close
Set rs = Nothing
db.Close
Response = acDataErrAdded
DoCmd.Hourglass False


End Sub
 
Back
Top