I tossed in the ADO update stuff simply to show how its done without giving much thought as to how khytonen might use it. An adOpenStatic, adLockReadOnly recordset isn't updateable anyway. Sorry for the vagueness. Got lazy.
I included it because I was speaking about using unbound
forms and controls (no Record Source or Control Source databinding properties set for forms or controls, respectively). Unbound forms used to add records require that the insert be done through code. Hence, the AddNew code block demonstration after thought.
quote:The combo box is going to be bound to the PK...
isn't happening. The combo box is unbound also (no ControlSource property set). It only serves as a sort of "query criteria viewer".
About the primary key thing, though. Say the Row Source property of the combo box is set to: "SELECT * FROM tblCustomers" and CustomerID is the primary key. Then you open a recordset based on tblCustomers and search for a record:
strSearch = "[CustomerID] = " & " '" & Me![cboSelect] & "'"
This brings you to the record in the recodset that satifies the criteria. Then:
rst!CustomerID = Me.cboSelect
will simply try and take that primary key value and put it back in tblCustomers. The value already exists as a primary key value in tblCustomers. So you get a duplicate primary key violation.
The point of the post was simply to show how to bind unbound textbox controls on an unbound form to an ADO recordset based on a value in an unbound combo box. Feel free to ingnore the PK comment. Thats just how I set up my test module.