Not in the List

G

Guest

I have a combo box that gives a list of instruments to pick from. If an
instrument is not in the list, is there a way to add it to the table from the
combo box?

Thanks
Wm.
 
A

Albert D. Kallal

You can set the limit to yes = to yes.

The, for the no in list event, you can use the following code:


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

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

End Sub

Note I used a table name of Students, and field name of Sname. So, just
change the table name, and the field to whatever you used.
 

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


Top