Adding items to combo boxes

  • Thread starter Thread starter Sue
  • Start date Start date
S

Sue

Sometimes I need to add an item to a dropdown list (combo
box). I have been doing that by actually adding the item
to the row source of the combo box. I have the combo
box "Limit to list" set to "no". Is there a way I can just
type in a new item and have it automatically put on the
row source? Thanks!
 
Sometimes I need to add an item to a dropdown list (combo
box). I have been doing that by actually adding the item
to the row source of the combo box. I have the combo
box "Limit to list" set to "no". Is there a way I can just
type in a new item and have it automatically put on the
row source? Thanks!

Unless you have some method to not add data that is simply a
mis-spelled word that's already in the list, you are going to have a
very long list.

Set the LimitToList property to Yes.

Code the NotInList event:

If MsgBox("Product is not in list. Add it?", vbOKCancel) = vbOK Then
Dim strSQL As String

strSQL = " INSERT INTO YourTable(FieldName) SELECT " & Chr(34) &
NewData & Chr(34) & ";"

CurrentDb.Execute strSQL, dbFailOnError
Response = acDataErrAdded
Else
Response = acDataErrContinue
End If
 
Thank you, Fred! I'm going to try it right away!
-----Original Message-----


Unless you have some method to not add data that is simply a
mis-spelled word that's already in the list, you are going to have a
very long list.

Set the LimitToList property to Yes.

Code the NotInList event:

If MsgBox("Product is not in list. Add it?", vbOKCancel) = vbOK Then
Dim strSQL As String

strSQL = " INSERT INTO YourTable(FieldName) SELECT " & Chr (34) &
NewData & Chr(34) & ";"

CurrentDb.Execute strSQL, dbFailOnError
Response = acDataErrAdded
Else
Response = acDataErrContinue
End If
--
Fred
Please only reply to this newsgroup.
I do not reply to personal email.
.
 
Back
Top