Combo Box

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I use a combo box on a form that links information from a
related table. When I click on the arrow the drop down
box shows a list of values already populated in the
table. When I type in a value that isn't currently in the
related table, I get an message saying it is an invalid
value. Is there any way that I can make this box read in
a new value into the related or must I always choose from
the drop down list?
 
You will need to place code into the combo's NotInList
eventhandler to populate the related table with the new
entry. Typically, the code in this eventhandler is along
the following lines

Private Sub combo(NewData As String, Response As Integer)
If MsgBox("Do You Wish to continue with new Value",
vbYesNo) = vbYes Then
<code here to add entry to table or open up another
form>
Response = acDataErrAdded
Else
combo.Undo
Response = acDataErrContinue
End If
End Sub

Hope This Helps
Gerald Stanley MCSD
 
Thanks for the response. I can't seem to use the additem
method to add the new entry. I used a query to populate
the combo box from the related table and I don't know if
that is what is not allowing me to complete the code. I
keep getting an error message when I try to run it.
 
You do not need to code the addtion of the entry into the
list. Once the new entry has been added into the table
that is the rowsource for the combo, it should appear in
the list.

Hope This Helps
Gerald Stanley MCSD
 
Back
Top