Forum Discussion
How to Update Table from a Form using cmd button
Okay I believe I am getting an error now due to Part_ID not = a number. Part_ID needs to be text.
It says:
"Syntax error (missing operator) in query expression 'Part_ID = Test blade'."
The form is bound to another table already. I'll leave that for now, although any process that involves putting records from a form into two different tables raises some concerns.
There are a couple of ways this could be going wrong, but the most likely is that the combo box is bound to the wrong field in the rowsource table.
Most of the time, the Primary Key for Access tables is an AutoNumber, which is Long Integer datatype.
The table you are using probably has such a field, called "Part_ID". However, it may be the case that your table actually has used the text value, such as "Test blade" as the field designated as the Primary Key. I'm going to start by assuming that you have a typical table, i.e. one with an Autonumber Primary Key.
If that is the case, the combo box should have two columns (or possibly more). The first column on the left is by default the bound column. It is the column in which the Part_ID is used and, I assume, it is the AutoNumber PK. Your combo box possibly is bound to the second column, though, and that would be the one intended to DISPLAY the text value for that PK. If so, that would result in the error you see.
The tricky part is the way Access refers to columns in combo and list boxes. Column 1, the first column on the left, is identified with an Index of 0, and the second column is Index 1, and so on.
So, in your VBA, to refer to the bound column, which again I assume is actually the AutoNumber PK, you'd use Me.prtnum_cbo.Column(0) or just plain Me.prtnum_cbo
The fact that you are getting a datatype mismatch means either that you did not include the actual Primary Key (Part_ID) in the combo box, or that it is not the first column, or that the combo box is bound to a different column, i.e. the second or third column which DISPLAYS the text value.
Sorting that out should correct the problem.