Adding new record in form/not pulling from combo

B

Brianne

I am in the process of designing a database that is pretty simple.

I have a form with one combo box linked to a query at the top to pull a
record by last name. When I add a new record in the form and then go back to
pull that record by last name it doesn't pull a record. The name is there in
the combo box but clicking on it does nothing.

TIA.
 
B

Brianne

I think that I solved that issue but now see that in my combo box for last
name I can't select people with the same last name. For example, if you have:

Smith, Allison
Smith, Jen
Smith, Rick

It only allows you to view Allison even if you click on Rick's name. Hm.
 
J

John W. Vinson

I think that I solved that issue but now see that in my combo box for last
name I can't select people with the same last name. For example, if you have:

Smith, Allison
Smith, Jen
Smith, Rick

It only allows you to view Allison even if you click on Rick's name. Hm.

Correct the error in your combo box's row source or in your code. If you would
like help doing so please post the rowsource and the code.
 
B

Brianne

The rowsource says, SELECT [lastnames].[last_name], [lastnames].[first_name]
FROM lastnames;

AND, I thought I had fixed the error where my new records show up in the
find record combo box but I'm back to the point where I can see the name but
I can't pull that record.
 
J

John W. Vinson

The rowsource says, SELECT [lastnames].[last_name], [lastnames].[first_name]
FROM lastnames;

AND, I thought I had fixed the error where my new records show up in the
find record combo box but I'm back to the point where I can see the name but
I can't pull that record.

Does your lastnames table have a primary key? As written, yes, it will find
only one instance of each last name. Worse, if you happen to have two people
who have the same name (I once worked at a university where there was a
professor named John W. Vinson, who was NOT me), you'll have no way to
distinguish them.

You really need a unique PersonID in your table - and to use THAT to find the
record, not the last name.
 
B

Brianne

The recordsource for the combo box is a query that just lists lastname and
firstname. The table (contacts) that the query is from does have a primary
key. I probably did it all wrong.

John W. Vinson said:
The rowsource says, SELECT [lastnames].[last_name], [lastnames].[first_name]
FROM lastnames;

AND, I thought I had fixed the error where my new records show up in the
find record combo box but I'm back to the point where I can see the name but
I can't pull that record.

Does your lastnames table have a primary key? As written, yes, it will find
only one instance of each last name. Worse, if you happen to have two people
who have the same name (I once worked at a university where there was a
professor named John W. Vinson, who was NOT me), you'll have no way to
distinguish them.

You really need a unique PersonID in your table - and to use THAT to find the
record, not the last name.
 
J

John W. Vinson

The recordsource for the combo box is a query that just lists lastname and
firstname. The table (contacts) that the query is from does have a primary
key. I probably did it all wrong.

Easy to do!

Try including the numeric ContactID field as the Bound Column of the combo
box; set its width to 0 in the ColumnWidths property of the combo so you don't
see it. If the combo is designed to find a record, use its AfterUpdate event
to find the desired record by ContactID rather than by name.
 

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