Form changes table data when it closes


D

DHRRush

I'm working with a variation on the Employees form from the Northwind
database. I have a form (called Lookup) with one field and a command
button to look up the employee by last name. On click, the table is
searched for matching record, and another form (called Employee) opens
with employee info and a picture.
So far, so good. Can close the Employee form and search for any number
of other employees using the Lookup form, all with good results.
Now, when done, I close the Lookup form. The first record in the
employees table changes the data in the LastName field to match the
info that was last entered in the Lookup form.
Why is that happening, and how do I stop it?
 
Ad

Advertisements

J

John Vinson

Why is that happening, and how do I stop it?

It's happening because you have your Combo Box bound to the name
field. When you select a name (intending to search for that name),
it's overwriting the value in the currently selected record in the
table - the first record in the sort order, presumably - with the name
that you selected.

Change the combo box's Control Source property to blank. Combos used
for searching should always be "unbound" - have nothing in their
Control Source property.

John W. Vinson[MVP]
 
D

DHRRush

John said:
It's happening because you have your Combo Box bound to the name
field. When you select a name (intending to search for that name),
it's overwriting the value in the currently selected record in the
table - the first record in the sort order, presumably - with the name
that you selected.

Change the combo box's Control Source property to blank. Combos used
for searching should always be "unbound" - have nothing in their
Control Source property.

John W. Vinson[MVP]


Thank you. I caught the error soon after I posted the question.
Should have known better
 
Ad

Advertisements

J

John Vinson

Thank you. I caught the error soon after I posted the question.
Should have known better

I'd be embarrassed to tell you how many times I've fallen into the
same trap!

John W. Vinson[MVP]
 

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