Combobox default lit & add new

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
 
K

Keith Wilby

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
 
P

PieterLinden via AccessMonster.com

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

Sure, why not? Set the default using the Default property of the combobox,
and then add code to the LimitToList event to allow new entries. Check the
NG, I'm sure there's code for it here somewhere.
 
D

Daniel Pineault

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

Top