Combo box problem - more than one with same last name

G

Guest

I have a combo box to select students on a form.

It works great, as long as no one else has the same last name. For example,
I have many Johnsons. My Combo box looks up students by name, but the First
Johnson is always the one chosen.
It works if I have Student ID be the first column and select students based
on their ID number, but then I can't search in the combo box by last name. I
want users to be able to click the dropdown arrow, start typing the last name
to get to the approx. part of the list (3000 names) then select the correct
student in the combo box. What am I missing??
 
G

Guest

Hiya Barbara,

Here's the way I do it. Others may have a better way. I use the following
in my row source for a combobox.

SELECT [ID], Trim([LastName] & ", " & [FirstName] & " " & [MiddleInitial])
AS FullName FROM Contacts ORDER BY [LastName], [FirstName], [MiddleInitial],
[ID];

That gives me names listed by lastname first (comma) firstname (space)
MiddleInitial. It also seems to be convenient in terms of parsing notInList
entries due to the comma giving me something to count on in terms of
someone's entry. I deny people if their entry doesn't have a comma, plus
when they start typing the dropdown list opens and they can clearly see the
format (last, first M).

You can add a "where" clause before the "order by" if you want to limit the
entries based on some other field.

Hope that's useful.
CW
 
G

Guest

Thanks so much for your response.
I have the combo box showing the choices, however, now it does not select
that student in the form. Also, I can't select it by Alpha (it is sorted that
way, but you can't type the first few letters to get to that part of the
list).

Any more ideas?

Cheese_whiz said:
Hiya Barbara,

Here's the way I do it. Others may have a better way. I use the following
in my row source for a combobox.

SELECT [ID], Trim([LastName] & ", " & [FirstName] & " " & [MiddleInitial])
AS FullName FROM Contacts ORDER BY [LastName], [FirstName], [MiddleInitial],
[ID];

That gives me names listed by lastname first (comma) firstname (space)
MiddleInitial. It also seems to be convenient in terms of parsing notInList
entries due to the comma giving me something to count on in terms of
someone's entry. I deny people if their entry doesn't have a comma, plus
when they start typing the dropdown list opens and they can clearly see the
format (last, first M).

You can add a "where" clause before the "order by" if you want to limit the
entries based on some other field.

Hope that's useful.
CW


BarbaraM said:
I have a combo box to select students on a form.

It works great, as long as no one else has the same last name. For example,
I have many Johnsons. My Combo box looks up students by name, but the First
Johnson is always the one chosen.
It works if I have Student ID be the first column and select students based
on their ID number, but then I can't search in the combo box by last name. I
want users to be able to click the dropdown arrow, start typing the last name
to get to the approx. part of the list (3000 names) then select the correct
student in the combo box. What am I missing??
 
J

John Spencer

The first column should be the primary key on your table. You can hide
that column by setting column widths to 0 for the first column. Keep
the control bound to the primary key column.

The second column should concatenate the last name, first name middle
initial (and if there are still duplicates, add something else at the
end to make it unique.

Now when you type you should be able to enter something like

Spencer, J

And have the combobox jump to the first row that has Spencer, J in it.

Your SQL for the combobox row source might look something like

SELECT StudentID, LastName & ", " & FirstName & " : " & StudentID
FROM YourTable
ORDER BY LastName, FirstName, StudentID

The display will just show the second column
Spencer, John : 99823


---
John Spencer
Access MVP 2001-2005, 2007

Thanks so much for your response.
I have the combo box showing the choices, however, now it does not select
that student in the form. Also, I can't select it by Alpha (it is sorted that
way, but you can't type the first few letters to get to that part of the
list).

Any more ideas?

Cheese_whiz said:
Hiya Barbara,

Here's the way I do it. Others may have a better way. I use the following
in my row source for a combobox.

SELECT [ID], Trim([LastName] & ", " & [FirstName] & " " & [MiddleInitial])
AS FullName FROM Contacts ORDER BY [LastName], [FirstName], [MiddleInitial],
[ID];

That gives me names listed by lastname first (comma) firstname (space)
MiddleInitial. It also seems to be convenient in terms of parsing notInList
entries due to the comma giving me something to count on in terms of
someone's entry. I deny people if their entry doesn't have a comma, plus
when they start typing the dropdown list opens and they can clearly see the
format (last, first M).

You can add a "where" clause before the "order by" if you want to limit the
entries based on some other field.

Hope that's useful.
CW


BarbaraM said:
I have a combo box to select students on a form.

It works great, as long as no one else has the same last name. For example,
I have many Johnsons. My Combo box looks up students by name, but the First
Johnson is always the one chosen.
It works if I have Student ID be the first column and select students based
on their ID number, but then I can't search in the combo box by last name. I
want users to be able to click the dropdown arrow, start typing the last name
to get to the approx. part of the list (3000 names) then select the correct
student in the combo box. What am I missing??
 

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

Similar Threads

Combo box record source 6
More Help Please 2
Setting up Tables 3
Help with Combo Box 4
Combo box synch question 2
rs.FindFirst to find last and first name 2
Combo Box Error 2
C# Skype silent connection 0

Top