Combobox Question

A

Aria

Hello,
Is there any way to have a combobox (cboFindAnEmployee) show the names in
alphabetical order no matter which order the records were entered? I mean
when you first open your database and not based on the first record? When I
first created the combobox and tested it to see if it was working, I used my
name for the first record and then others to test it. Quite frankly, I'm sick
of seeing my name in the combobox since I'm towards the end of the alphabet.
I would like whomever has the last name that starts the "A"s to show first. I
know it's nitpicky but what can I say...

I don't know if you need this info but here it it:
SQL
***
SELECT tblEmployees.EmpID, [LastName] & ", " & [FirstName] AS LastFirst
FROM tblEmployees
ORDER BY [LastName] & ", " & [FirstName], tblEmployees.LastName,
tblEmployees.FirstName;

Thank you for any suggestions.
 
K

Ken Snell \(MVP\)

If the SQL statement that you posted is the query that is being used as the
cboFindAnEmployee combobox's RowSource query, then the combobox should be
behaving as you wish.

If you have something else for the combobox's RowSource property, post that
for us to assist you.
 
A

Aria

Thanks for responding. I believe the SQL statement indicates that it *is*
sorted by the last name. What I am looking to see is the name that begins the
alpha list in the combobox. I hope that makes sense. For example, the first
name in my combobox has a last name that starts with "Ab". I would *like* to
see this name first, intead of "W" (which begins my last name). If I then
have to input a last name that begins with "Aa" then *that* name is
automatically shown in the combo. Any suggestions?
--
Aria W.


troy23 said:
Can you not sort by last name in the query behind the combo box?

For FREE Access ebook and videos click here
http://access-databases.com/ebook

Hello,
Is there any way to have a combobox (cboFindAnEmployee) show the names in
alphabetical order no matter which order the records were entered? I mean
when you first open your database and not based on the first record? When I
first created the combobox and tested it to see if it was working, I used my
name for the first record and then others to test it. Quite frankly, I'm sick
of seeing my name in the combobox since I'm towards the end of the alphabet.
I would like whomever has the last name that starts the "A"s to show first. I
know it's nitpicky but what can I say...

I don't know if you need this info but here it it:
SQL
***
SELECT tblEmployees.EmpID, [LastName] & ", " & [FirstName] AS LastFirst
FROM tblEmployees
ORDER BY [LastName] & ", " & [FirstName], tblEmployees.LastName,
tblEmployees.FirstName;

Thank you for any suggestions.
 
B

Beetle

That's happening because of the code in the forms
Current event that keeps the search box in synch
with the current record. Your name is the first record
in the table, so when the form opens the Current event
fires and moves the combo box to your name. If you don't
want that to happen, open the code window for the
Current event and comment out this line;

Me.cboFindAnEmployee = Me.EmpID

Cheers
 
A

Aria

I'm sorry, I must not be explaining very well.

The RowSource is:
SELECT [tblEmployees].[EmpID], [LastName] & ", " & [FirstName] AS LastFirst
FROM tblEmployees ORDER BY [LastName] & ", " & [FirstName],
[tblEmployees].[LastName], [tblEmployees].[FirstName];

What I see:
In cboFindAnEmployee my name is shown in the box, I believe, because it is
the first record I input. When you click on the drop-down arrow, all
additional names are listed in alphabetical order.

What I would like to see:
Whomever has the first name in the list, their name shown in the box. If I
input another record that falls ahead of that person in the alphabet, *their
name is shown in the box first.

Sorry for the confusion, I hope that explains a little better.
--
Aria W.


Ken Snell (MVP) said:
If the SQL statement that you posted is the query that is being used as the
cboFindAnEmployee combobox's RowSource query, then the combobox should be
behaving as you wish.

If you have something else for the combobox's RowSource property, post that
for us to assist you.

--

Ken Snell
<MS ACCESS MVP>
http://www.accessmvp.com/KDSnell/


Aria said:
Hello,
Is there any way to have a combobox (cboFindAnEmployee) show the names in
alphabetical order no matter which order the records were entered? I mean
when you first open your database and not based on the first record? When
I
first created the combobox and tested it to see if it was working, I used
my
name for the first record and then others to test it. Quite frankly, I'm
sick
of seeing my name in the combobox since I'm towards the end of the
alphabet.
I would like whomever has the last name that starts the "A"s to show
first. I
know it's nitpicky but what can I say...

I don't know if you need this info but here it it:
SQL
***
SELECT tblEmployees.EmpID, [LastName] & ", " & [FirstName] AS LastFirst
FROM tblEmployees
ORDER BY [LastName] & ", " & [FirstName], tblEmployees.LastName,
tblEmployees.FirstName;

Thank you for any suggestions.
 
A

Aria

Hi,
OK, I tried it and it's not quite what I was looking for but I do see what
everyone is trying to tell me now. After following your suggestion, my name
is removed and it doesn't show any name. So the answer would be I either keep
the combo in synch with the current (1st) record or leave the space blank,
correct? I can't show record #79 (for instance) just because the last name
happens to come first in the alphabet.
--
Aria W.


Beetle said:
That's happening because of the code in the forms
Current event that keeps the search box in synch
with the current record. Your name is the first record
in the table, so when the form opens the Current event
fires and moves the combo box to your name. If you don't
want that to happen, open the code window for the
Current event and comment out this line;

Me.cboFindAnEmployee = Me.EmpID

Cheers
--
_________

Sean Bailey


Aria said:
Hello,
Is there any way to have a combobox (cboFindAnEmployee) show the names in
alphabetical order no matter which order the records were entered? I mean
when you first open your database and not based on the first record? When I
first created the combobox and tested it to see if it was working, I used my
name for the first record and then others to test it. Quite frankly, I'm sick
of seeing my name in the combobox since I'm towards the end of the alphabet.
I would like whomever has the last name that starts the "A"s to show first. I
know it's nitpicky but what can I say...

I don't know if you need this info but here it it:
SQL
***
SELECT tblEmployees.EmpID, [LastName] & ", " & [FirstName] AS LastFirst
FROM tblEmployees
ORDER BY [LastName] & ", " & [FirstName], tblEmployees.LastName,
tblEmployees.FirstName;

Thank you for any suggestions.
 
B

Beetle

You can use Me.cboFindAnEmployee = Me.cboFindAnEmployee.ItemData(0)
to get it to display the first name in the sort order. If you use this in
your forms
Open event it will move to the first name when the form opens, but after
that it will
display whichever name was selected last (as long as it isn't requeried by
some
other method). You could also use the Current event, but then it will move
back
to the first name every time you change records (which you may not want).
--
_________

Sean Bailey


Aria said:
Hi,
OK, I tried it and it's not quite what I was looking for but I do see what
everyone is trying to tell me now. After following your suggestion, my name
is removed and it doesn't show any name. So the answer would be I either keep
the combo in synch with the current (1st) record or leave the space blank,
correct? I can't show record #79 (for instance) just because the last name
happens to come first in the alphabet.
--
Aria W.


Beetle said:
That's happening because of the code in the forms
Current event that keeps the search box in synch
with the current record. Your name is the first record
in the table, so when the form opens the Current event
fires and moves the combo box to your name. If you don't
want that to happen, open the code window for the
Current event and comment out this line;

Me.cboFindAnEmployee = Me.EmpID

Cheers
--
_________

Sean Bailey


Aria said:
Hello,
Is there any way to have a combobox (cboFindAnEmployee) show the names in
alphabetical order no matter which order the records were entered? I mean
when you first open your database and not based on the first record? When I
first created the combobox and tested it to see if it was working, I used my
name for the first record and then others to test it. Quite frankly, I'm sick
of seeing my name in the combobox since I'm towards the end of the alphabet.
I would like whomever has the last name that starts the "A"s to show first. I
know it's nitpicky but what can I say...

I don't know if you need this info but here it it:
SQL
***
SELECT tblEmployees.EmpID, [LastName] & ", " & [FirstName] AS LastFirst
FROM tblEmployees
ORDER BY [LastName] & ", " & [FirstName], tblEmployees.LastName,
tblEmployees.FirstName;

Thank you for any suggestions.
 
A

Aria

Thank you! That's exactly what I wanted.
--
Aria W.


Beetle said:
You can use Me.cboFindAnEmployee = Me.cboFindAnEmployee.ItemData(0)
to get it to display the first name in the sort order. If you use this in
your forms
Open event it will move to the first name when the form opens, but after
that it will
display whichever name was selected last (as long as it isn't requeried by
some
other method). You could also use the Current event, but then it will move
back
to the first name every time you change records (which you may not want).
--
_________

Sean Bailey


Aria said:
Hi,
OK, I tried it and it's not quite what I was looking for but I do see what
everyone is trying to tell me now. After following your suggestion, my name
is removed and it doesn't show any name. So the answer would be I either keep
the combo in synch with the current (1st) record or leave the space blank,
correct? I can't show record #79 (for instance) just because the last name
happens to come first in the alphabet.
--
Aria W.


Beetle said:
That's happening because of the code in the forms
Current event that keeps the search box in synch
with the current record. Your name is the first record
in the table, so when the form opens the Current event
fires and moves the combo box to your name. If you don't
want that to happen, open the code window for the
Current event and comment out this line;

Me.cboFindAnEmployee = Me.EmpID

Cheers
--
_________

Sean Bailey


:


Hello,
Is there any way to have a combobox (cboFindAnEmployee) show the names in
alphabetical order no matter which order the records were entered? I mean
when you first open your database and not based on the first record? When I
first created the combobox and tested it to see if it was working, I used my
name for the first record and then others to test it. Quite frankly, I'm sick
of seeing my name in the combobox since I'm towards the end of the alphabet.
I would like whomever has the last name that starts the "A"s to show first. I
know it's nitpicky but what can I say...

I don't know if you need this info but here it it:
SQL
***
SELECT tblEmployees.EmpID, [LastName] & ", " & [FirstName] AS LastFirst
FROM tblEmployees
ORDER BY [LastName] & ", " & [FirstName], tblEmployees.LastName,
tblEmployees.FirstName;

Thank you for any suggestions.
 

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