Add-To Combo Box

M

Martin

Hello,
Does anyone out there know what I have to do to make
an "Add-To" combo box work? I want to have a combo box
with names that, when the user types a name that is not
in the list, adds it to the table after a prompt.
I'm not good with VBA, but I'm good with
instructions. Pretty much, as Barney as possible would be
nice being that I need to learn as I go right now.

Thanks in advance.
 
J

Jim/Chris

Set limit to list to yes and add this code on the Not in
List event for your combo box Where tblname is the name of
the table for your list source

Dim strSql As String
If MsgBox(NewData & " not in list, add?", _
vbYesNo + vbQuestion) = vbYes Then
strSql = "insert into tblname (name) values('" &
NewData & "')"
CurrentDb.Execute strSql
Response = acDataErrAdded
End If

Jim
 
M

Martin

Thanks for the solution!
-----Original Message-----
Set limit to list to yes and add this code on the Not in
List event for your combo box Where tblname is the name of
the table for your list source

Dim strSql As String
If MsgBox(NewData & " not in list, add?", _
vbYesNo + vbQuestion) = vbYes Then
strSql = "insert into tblname (name) values('" &
NewData & "')"
CurrentDb.Execute strSql
Response = acDataErrAdded
End If

Jim

.
 

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