Populate table with combo box

tMitch

Registered User.
Local time
Today, 17:11
Joined
Sep 24, 2002
Messages
43
Trying again:

I want to populate a table (tblMHDPlantList) with records from another table (tblPlantList) using a combo box in a form. I then want to update the new tblMHDPlantList records in the form. The combo box works if the record is already in tblMHDPlantList. However, when I select a new plant to add from the combo box (unbound to tblPlantList) I get the message: “Index or primary key cannot contain a null value.” TblMHDPlantList also has foreign ID key to tbl_Plant_Type. I have another combo box to choose plant type.

I am able to update tblMHDPlantList by adding the table as a subform/subreport to a form that also allows me to add new plants to tblPlantList. However, this is in table form and doesn’t allow me to use combo boxes, which I need because ID key numbers don’t mean much to a user.

Is there some kind of code that I need to tell tblMHDPlantList to add a new autonumber field if the ID number (from cboBox) is not already in the table? I don’t know how to write code and I have been stuck with this for a long time!!

Thank you!
 
If you go with the subform datasheet view, you can just tie the subform to a query instead of a table. That way you can display pertinent data instead of ID's.

The way you describe the problem, I take it you're tying to add a new record to the table any time a value is selected from the combo? I would suggest having multiple combos from which you select, then have a button that adds the complete record.
 

Users who are viewing this thread

Back
Top Bottom