dbTalk Databases Forums  

Sorting a form via Combo box

comp.databases.ms-access comp.databases.ms-access


Discuss Sorting a form via Combo box in the comp.databases.ms-access forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
RLN
 
Posts: n/a

Default Sorting a form via Combo box - 03-07-2008 , 10:02 AM






Re: Access 2003
I have a form that has tableX as its data source, and the form displays
data in "continuous forms" view.

While there are about 12 columns in this datasheet view, the user wants
to be able to sort the data from choosing a field in a combo box.

When this form loads, does anyone have a code sample that loads the
column names of the table into a combo box that would use the
Description of the column (not theactual clumn name) then when a column
is chosen from this combo it would sort data in ascending order?

Thnx.....
RLN

*** Sent via Developersdex http://www.developersdex.com ***

Reply With Quote
  #2  
Old   
Allen Browne
 
Posts: n/a

Default Re: Sorting a form via Combo box - 03-07-2008 , 10:23 AM






That's not the simplest thing in the world: code that examines all the
controls on your form in Form_Load, figues out which ones you can sort by,
identifies the field name to sort by and the name by which the user actually
knows the field (typically by identifying the attached label for forms in
Form view, or the label over the column for forms in Continuous View), and
loads both names into the columns of the combo (field names hidden,
user-names displayed), so the user can sort the form.

The sorting is easy: just set the OrderBy property of the form. For the rest
of it, you could use something like this code:
http://allenbrowne.com/AppFindAsUTypeCode.html

That utility does something similar, for the purpose of filtering rather
than sorting. You could adapt it easily enough, as the sorting part is easy.

You mentioned using the Description of the field rather than it's Name. If
you want to do that, this example shows how to get the Description property
if it exists for a field:
http://allenbrowne.com/func-06.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"RLN" <nospam (AT) devdex (DOT) com> wrote

Quote:
Re: Access 2003
I have a form that has tableX as its data source, and the form displays
data in "continuous forms" view.

While there are about 12 columns in this datasheet view, the user wants
to be able to sort the data from choosing a field in a combo box.

When this form loads, does anyone have a code sample that loads the
column names of the table into a combo box that would use the
Description of the column (not theactual clumn name) then when a column
is chosen from this combo it would sort data in ascending order?


Reply With Quote
  #3  
Old   
frogsteaks@yahoo.com
 
Posts: n/a

Default Re: Sorting a form via Combo box - 03-10-2008 , 10:58 AM



On Mar 7, 12:02*pm, RLN <nos... (AT) devdex (DOT) com> wrote:
Quote:
Re: Access 2003
I have a form that has tableX as its data source, and the form displays
data in "continuous forms" view.

While there are about 12 columns in this datasheet view, the user wants
to be able to sort the data from choosing a field in a combo box.

When this form loads, does anyone have a code sample that loads the
column names of the table into a combo box that would use the
Description of the column (not theactual clumn name) then when a column
is chosen from this combo it would sort data in ascending order?

Thnx.....
RLN

*** Sent via Developersdexhttp://www.developersdex.com***
Populate your combo box with two columns. The first column would be
the field name displayed to the user (a human friendly description of
the field to sort on), the second column would be the actual related
field name in the tabel that is the source for the main form. Then on
the after update event on the combo box put code something like
this...

me.orderby = me.comboxboxnname.column(1)

You may need to tweak that some. Not sure if I have the syntax 100%
correct.


Reply With Quote
Reply




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 On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.