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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

add newdata to combo box and save to the original table

Status
Not open for further replies.

ronaldlee

IS-IT--Management
Oct 31, 2002
9
0
0
HK
Please advis how to do to save the newdata to the original Table or Form when it is not in the list and it will automatically update the newdata to the combo box list, not need to refresh it by manual

I have tried "event - NoInlist" to pop up the originl form to key in the newdata but it is only update the original form. It should refresh the comb BOx to have the newdata in list.

Please kindly provide solution

Thank you
 
This is how the NotInList event should work. You need to make sure that your "Limit To List" property is set to "Yes".


Private Sub YourField_NotInList(NewData As String, Response As Integer)
Dim ctl As Control
Set ctl = Me!YourField

If MsgBox("Would you like to add " & NewData & " to the list??", vbYesNo + vbQuestion) = vbYes Then
Response = acDataErrAdded
CurrentDb.Execute "INSERT INTO YourTable (YourField) SELECT '" & NewData & "'"
Else
Response = acDataErrContinue
ctl.Undo
End If
End Sub Jim Lunde
compugeeks@hotmail.com
We all agree your theory is crazy, but is it crazy enough?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top