Combo box assigned to a field not working

R

rmccafferty

I have a combo box that I set up with the wizard. It is based on a table and
uses the 3rd option of searching for an existing record. The wizard allows me
to set up the lookup with 2 fields, Fname and Lname in my Customers table.
When the selection is made, the last name appears as the result in the combo
box, which is what I want.

If I assign this control (the combo box) to the last name field, when I do a
lookup and make a selection from the drop down box, I get an error message
that says:

You tried to call Update or CancelUpdate or attempted to update a Field in a
recordset without first calling AddNew or Edit. (Error 3020)

If I keep the combo box control as unbound and have a separate bound control
for last name, then it works fine. But that seems stupid to have two controls
both showing the last name field, and potentially very confusing to the users.


How do I just let the entry default to the last name field in the underlying
table?
 
A

Allen Browne

You can get the combo to show both the last name and the first name by
setting its RowSource like this:
SELECT Customers.ID,
Customers.Lname & ", " + Customers.Fname AS FullName
FROM Customers
ORDER BY Lname, Fname;

Change the ID into whatever is the primary key of your customers table, and
set these properties for the combo:
Bound Column 1
Column Count 2
Column Widths 0

If the purpose of the combo is to find a record, make it unbound (nothing in
its Control Source property.) If its purpose is to assign a customer to a
record, you will have a field name in its Control Source. If you are trying
to do both, use 2 combos: an unbound one for moving record, and a bound one
for assigning a field.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top