Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Add New Value to Combo Box

Status
Not open for further replies.

csunsun

Technical User
Apr 29, 2003
41
US
Hi!

I have a Combo Box in a form pulling values from a Lookup Table.

If a user enters a new value, what code/macro do I use to add the new value to the Lookup Table?

THANKS!!!!
 
Se the tab at the top of this forum page marked "faqs"? Click it, and find a whole section devoted to combos;-)

I'd recommend the faq on Add New Item to List, by KenReay, have a look, and post back if you're having problems...

Roy-Vidar
 
Make sure the Combo's "limit to list" property is set to yes. Create a form to add the new data on. Then under "NotInList" event add something like this...

Private Sub cboCaseNumber_NotInList(NewData As String, Response As Integer)
On Error GoTo Err_cboCaseNumber_NotInList
Dim intNewCategory As Integer, strTitle As String, intMsgDialog As Integer
strTitle = "CASE NUMBER NOT FOUND"
intMsgDialog = vbYesNo + vbQuestion + vbDefaultButton1
intNewCategory = MsgBox("Do you want to add this Case Number?", intMsgDialog, strTitle)
If intNewCategory = vbYes Then
DoCmd.RunCommand acCmdUndo
DoCmd.OpenForm "formNewCaseNumber", acNormal, , , acFormAdd, acDialog, NewData
Response = acDataErrAdded
End If
Exit_cboCaseNumber_NotInList:
Exit Sub
Err_cboCaseNumber_NotInList:
MsgBox Err.Description
Resume Exit_cboCaseNumber_NotInList
End Sub

I just copied this from one of my databases...hope it helps.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top