I know I need to use the notinlist command and limit items to only in the list, but what is the event procedure to be used? For example, the table that stores is list is called OS, and the main table is simply called Main. thanx!
Here is an example of a NotInList Event Procedure which updates a table with the data from the ComboBox entry. If there are other fields in the table that need to be updated then you will have to either prompt for them or open another form in acDialog mode so that the user can enter the entire record and all of the data for that record.
Dim db As DAO.Database
Dim rs As DAO.Recordset
' Prompt user to verify they wish to add new value.
If MsgBox("Value is not in list. Add it?", vbOKCancel) = vbOK Then
' Set Response argument to indicate that data is being added.
Response = acDataErrAdded
' Add string in NewData argument to row source.
Set db = CurrentDb
Set rs = db.OpenRecordset("OS", dbOpenDynaset)
rs.AddNew
rs("YourFieldName" = NewData
rs.Update
rs.CLOSE
db.CLOSE
Else
' If user chooses Cancel, suppress error message and undo changes.
Response = acDataErrContinue
End If
Please post back if you have further questions.
Bob Scriver Want the best answers? See FAQ181-2886 Nobody believes the official spokesman... but everybody trusts an unidentified source.
Author, Bagdad Bob???
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.