Reputation: 21
I have a table called tblLotNum and a table called tblTimeCards.
tblTimeCards has a lookup field linked back to tblLotNum. Can I add new values to this lookup field while in the tblTimeCards table? If so, how?
I created a form frmTimeReporting that is based off of the fields from tblTimeCards. It is for data entry, as the interface for the person entering in the time. I cannot get the form to allow me to add new entries to what is ultimately the tblLotNum - can anyone help?
Upvotes: 2
Views: 58
Reputation: 112372
You can use the ComboBox.NotInList Event
in order to add new entries in the combo box. (follow the link for a detailed description).
Another possibility is to place a button next to the combo box that opens a new form where you can edit the tblLotNum table. The difficulty here is to requery the combo box once you have made edits to this table in order to make it display the new entries. The easiest approach is to open the new form in as a dialog (i.e. in a modal mode).
DoCmd.OpenForm "frmEditLotNums", WindowMode = AcWindowMode.acDialog
myComboBox.Requery
"Modal" means that the code opening the form pauses until the form is closed. Only then the following statement is executed.
Upvotes: 1
Reputation: 2227
The idea of a lookup field is that it is read-only, not unlike a view (a classic view, not an updatable view). So no, you can't add a value to table A via table B if a field in table A is used as a lookup field for table B. What you can do is add a value to the field in table A that serves as a lookup field for table B and then requery/refresh the interface object you are using to display the lookup field values (such as a drop-down list box, etc.)
Upvotes: 1