Can I use the List Box Col Heads to sort?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a search form that displays results in a list box. The list box has 7
columns. Rather than creating labels as a heading for each column I used the
heading feature of the list box to display the heading .ColumnHeads=True.

I am wondering if there is a double click cmd feature that can identify
which column heading I click on so I can retrigger the query with a sort
based on the column heading.

I know how to write the query that is not a problem, and I already have code
that when I double click on a item in the list a new form opens with the some
additional information based on the item clicked on. What I am not sure about
is how to identify which column of the row I have clicked in, is it even
possible.
 
Krista,
Drop the real column headings, and place buttons or text controls just above the
listbox... like headers.
When you click those objects, you can change the RowSource query, on the fly.
Ex.
[ Name ][ Address ] <= Click these to resort the list
Bob Jones 12 Main St
Jane Doe 22 Street
etc....

--
hth
Al Campagna . Candia Computer Consulting . Candia, NH USA
Microsoft Access MVP
http://home.comcast.net/~cccsolutions

"Find a job that you love, and you'll never work a day in your life."
 
ok, I was hoping there was a way to do it with the headings, but I guess not.
I have 6 search forms to update - will take longer than I had hoped. Thanks.

Al Campagna said:
Krista,
Drop the real column headings, and place buttons or text controls just above the
listbox... like headers.
When you click those objects, you can change the RowSource query, on the fly.
Ex.
[ Name ][ Address ] <= Click these to resort the list
Bob Jones 12 Main St
Jane Doe 22 Street
etc....

--
hth
Al Campagna . Candia Computer Consulting . Candia, NH USA
Microsoft Access MVP
http://home.comcast.net/~cccsolutions

"Find a job that you love, and you'll never work a day in your life."

Krista H said:
I have a search form that displays results in a list box. The list box has 7
columns. Rather than creating labels as a heading for each column I used the
heading feature of the list box to display the heading .ColumnHeads=True.

I am wondering if there is a double click cmd feature that can identify
which column heading I click on so I can retrigger the query with a sort
based on the column heading.

I know how to write the query that is not a problem, and I already have code
that when I double click on a item in the list a new form opens with the some
additional information based on the item clicked on. What I am not sure about
is how to identify which column of the row I have clicked in, is it even
possible.
 
Krista said:
I have a search form that displays results in a list box. The list box has 7
columns. Rather than creating labels as a heading for each column I used the
heading feature of the list box to display the heading .ColumnHeads=True.

I am wondering if there is a double click cmd feature that can identify
which column heading I click on so I can retrigger the query with a sort
based on the column heading.

I know how to write the query that is not a problem, and I already have code
that when I double click on a item in the list a new form opens with the some
additional information based on the item clicked on. What I am not sure about
is how to identify which column of the row I have clicked in, is it even
possible.


You can easily use your labels or command buttons, but what
you're asking can be a very tricky problem.

In the simplest situation, without any horizontal scrolling,
you can use the MouseUp event to capture a right click's X,Y
coordinates. The Y coordinate can then tell you if the
click was in the header row.

Determining the column from the X coordinate is reasonable
only if the ColumnWidths property is specified for every
column (determining the width when it's not specified is
another complex question). If you do specify all of the
column widths you can parse the property and calculate the
start and end coordinates of each column and from that
figure out which one was clicked.

After doing all that, you can then reconstruct the list
box's row source SQL statement with the right cliked column
in the ORDER BY clause.
 
Krista,
There are no events associated with column headers in combos or lisboxes... like Click
or Enter.

You could make the buttons or text controls "over" the columns, and the listbox itself,
a pop up form, or a subform.
Build once... use many...

Or, once you build one setup, you can copy and paste that into your other forms.
Or, consider using a datasheet subform like a listbox. You could sort on any column
"on the fly."
--
hth
Al Campagna . Candia Computer Consulting . Candia, NH USA
Microsoft Access MVP
http://home.comcast.net/~cccsolutions

"Find a job that you love, and you'll never work a day in your life."

Krista H said:
ok, I was hoping there was a way to do it with the headings, but I guess not.
I have 6 search forms to update - will take longer than I had hoped. Thanks.

Al Campagna said:
Krista,
Drop the real column headings, and place buttons or text controls just above the
listbox... like headers.
When you click those objects, you can change the RowSource query, on the fly.
Ex.
[ Name ][ Address ] <= Click these to resort the list
Bob Jones 12 Main St
Jane Doe 22 Street
etc....

--
hth
Al Campagna . Candia Computer Consulting . Candia, NH USA
Microsoft Access MVP
http://home.comcast.net/~cccsolutions

"Find a job that you love, and you'll never work a day in your life."

Krista H said:
I have a search form that displays results in a list box. The list box has 7
columns. Rather than creating labels as a heading for each column I used the
heading feature of the list box to display the heading .ColumnHeads=True.

I am wondering if there is a double click cmd feature that can identify
which column heading I click on so I can retrigger the query with a sort
based on the column heading.

I know how to write the query that is not a problem, and I already have code
that when I double click on a item in the list a new form opens with the some
additional information based on the item clicked on. What I am not sure about
is how to identify which column of the row I have clicked in, is it even
possible.
 
Back
Top