Hello,
I am using Access 2007 and am having trouble with notinlist event.
I am trying to update a combobox on the fly using NotinList event. I have a table called tbl_cities with only 1 field 'City'. When user entere a new city then I want to add the new and udpate the combobox.
The sql command works meaning the new value gets inserted but my combobox doesn't gets updated so i keep getting error then the value is not in list. when i exit the form without saving and reopen then i can see the new value in the list. Any suggestions would help. thanks.
I am using Access 2007 and am having trouble with notinlist event.
I am trying to update a combobox on the fly using NotinList event. I have a table called tbl_cities with only 1 field 'City'. When user entere a new city then I want to add the new and udpate the combobox.
The sql command works meaning the new value gets inserted but my combobox doesn't gets updated so i keep getting error then the value is not in list. when i exit the form without saving and reopen then i can see the new value in the list. Any suggestions would help. thanks.
Code:
Private Sub City_NotInList(NewData As String, Response As Integer)
sqlstring = "INSERT INTO tbl_cities (City) VALUES ('" & NewData & "')"
DoCmd.RunSQL sqlstring
Response = acErrDataAdded
End Sub