Below sequence examplifies List2 (listbox) with control
source pointing to table1 (3 fields, type Text)
This adds a new entry in the listbox ...
Eventhough below example is useless, it adds an entry to yr list or
combobox, as that is what you asked
Is there anything you can pick up from below sequence?
If not, pls indicate what y're after.
Private Sub List2_DblClick(Cancel As Integer)
CurrentProject.Connection.Execute _
"insert into table1 values ('123', '32', 'asdf')"
Ok. I have a combo box on a form labled "Model" that corresponds to table of
the same name. Since new models are added all the time, I need to be able to
add them to the table directly from the combo box.
You will need to check whether new models are not already in yr table.
Look at NonInList event
Something like:
Private Sub Combo7_NotInList(NewData As String, Response As Integer)
If MsgBox("New model. Enter in list?", vbYesNo) = vbYes Then
Me.Combo7.ControlSource = ""
CurrentDb.Execute "insert into model values ('" & NewData & "')"
Me.Combo7.Requery
Else
Me.Combo7.Dropdown
End If
Response = acDataErrContinue
End Sub
Private Sub Combo7_NotInList(NewData As String, Response As Integer)
If MsgBox("New model. Enter in list?", vbYesNo) = vbYes Then
CurrentDb.Execute "insert into model values ('" & NewData & "')"
Response = acDataErrAdded
Else
Me.Combo7.Dropdown
Response = acDataErrContinue
End If
End Sub
Private Sub Combo7_NotInList(NewData As String, Response As Integer)
If MsgBox("New model. Enter in list?", vbYesNo) = vbYes Then
CurrentDb.Execute "insert into model values ('" & NewData & "')"
Response = acDataErrAdded
Else
Me.Combo7.Dropdown
Response = acDataErrContinue
End If
End Sub
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.