A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

datasheet: ¿how to order by the 2nd column of a combobox?



 
 
Thread Tools Display Modes
  #1  
Old May 4th, 2010, 07:26 PM posted to microsoft.public.access.forms
robeito
external usenet poster
 
Posts: 4
Default datasheet: ¿how to order by the 2nd column of a combobox?

hello there!

In my form there is a field "idCountry", but I don't want to see the number,
instead, I want to show the country name, so I changed the control to a
combobox and the rowsource is "select id,name from countryCat"... etc. etc.

It works fine, but there is a problem, when I try to sort the data sheet by
that field (using the right click button of the mouse), actually it is sorted
by the "ID" of the country instead of its name.

I want to see the datasheet sorted by the real names of the countries, not
by its IDs

any sugestions?

thanks in advance
Ads
  #2  
Old May 4th, 2010, 08:07 PM posted to microsoft.public.access.forms
Daryl S[_2_]
external usenet poster
 
Posts: 881
Default datasheet: ¿how to order by the 2nd column of a combobox?

Robeito -

In your "select id,..." statement, add in this at the end:

ORDER BY [name]

Note you should not use "name" for the name of a field - it is a reserved
word and will cause you problems. Until you get it fixed, remember to always
put square brackets around it, including in the SELECT statement.

--
Daryl S


"robeito" wrote:

hello there!

In my form there is a field "idCountry", but I don't want to see the number,
instead, I want to show the country name, so I changed the control to a
combobox and the rowsource is "select id,name from countryCat"... etc. etc.

It works fine, but there is a problem, when I try to sort the data sheet by
that field (using the right click button of the mouse), actually it is sorted
by the "ID" of the country instead of its name.

I want to see the datasheet sorted by the real names of the countries, not
by its IDs

any sugestions?

thanks in advance

  #3  
Old May 4th, 2010, 09:04 PM posted to microsoft.public.access.forms
robeito
external usenet poster
 
Posts: 4
Default datasheet: ¿how to order by the 2nd column of a combobox?

Thanks Daryl:

I must clarify my post:

Actually the data grid shows the information as I spected, but, when I use
the standar right click action of the mouse on the grid (sort A-Z, sort
Z-A, cut, copy paste, filter,...) and use the sort option, the grid is
sorted by the countries ID and that's not what I want, I want the grid sorted
by the alphanumeric name of the country








"Daryl S" wrote:

Robeito -

In your "select id,..." statement, add in this at the end:

ORDER BY [name]

Note you should not use "name" for the name of a field - it is a reserved
word and will cause you problems. Until you get it fixed, remember to always
put square brackets around it, including in the SELECT statement.

--
Daryl S


"robeito" wrote:

hello there!

In my form there is a field "idCountry", but I don't want to see the number,
instead, I want to show the country name, so I changed the control to a
combobox and the rowsource is "select id,name from countryCat"... etc. etc.

It works fine, but there is a problem, when I try to sort the data sheet by
that field (using the right click button of the mouse), actually it is sorted
by the "ID" of the country instead of its name.

I want to see the datasheet sorted by the real names of the countries, not
by its IDs

any sugestions?

thanks in advance

  #4  
Old May 4th, 2010, 09:47 PM posted to microsoft.public.access.forms
John W. Vinson
external usenet poster
 
Posts: 18,261
Default datasheet: how to order by the 2nd column of a combobox?

On Tue, 4 May 2010 13:04:01 -0700, robeito
wrote:

Thanks Daryl:

I must clarify my post:

Actually the data grid shows the information as I spected, but, when I use
the standar right click action of the mouse on the grid (sort A-Z, sort
Z-A, cut, copy paste, filter,...) and use the sort option, the grid is
sorted by the countries ID and that's not what I want, I want the grid sorted
by the alphanumeric name of the country


Then you will have to base the datasheet on a Query including the country
table.

The combo box is not data, is not part of your table, and is not something you
can sort: it's just a display tool, displaying data from *a different table*
(the combo's rowsource).
--

John W. Vinson [MVP]
  #5  
Old May 5th, 2010, 05:08 PM posted to microsoft.public.access.forms
Daryl S[_2_]
external usenet poster
 
Posts: 881
Default datasheet: ?how to order by the 2nd column of a combobox?

Robeito -

Like John said, add the Country table to the query behind the form and use
that name in your form. You can hide this field if you want and still sort
on it, so the user interface is the same as what you have. Or, if the form
is not meant for updates, you could remove the combo box and just show the
country name.

--
Daryl S


"John W. Vinson" wrote:

On Tue, 4 May 2010 13:04:01 -0700, robeito
wrote:

Thanks Daryl:

I must clarify my post:

Actually the data grid shows the information as I spected, but, when I use
the standar right click action of the mouse on the grid (sort A-Z, sort
Z-A, cut, copy paste, filter,...) and use the sort option, the grid is
sorted by the countries ID and that's not what I want, I want the grid sorted
by the alphanumeric name of the country


Then you will have to base the datasheet on a Query including the country
table.

The combo box is not data, is not part of your table, and is not something you
can sort: it's just a display tool, displaying data from *a different table*
(the combo's rowsource).
--

John W. Vinson [MVP]
.

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 08:33 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
Copyright 2004-2019 OfficeFrustration.
The comments are property of their posters.