473,386 Members | 1,766 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Listbox Positioning

I want a listbox to position to a letter provided by the user.
Normally, when the user keys a letter, the listbox positions
automatically to the first entry starting with that letter in the
first column.

I want to allow the user to select the column to be searched.

For eaxample, assume a list box that looks like this:

____________________________
| Title | Author |
|----------|----------------|
| Oklahoma | Hammerstein, O |
| Hamlet | Shakespeare, W |
Nov 12 '05 #1
3 2474
DFS
Mike,

No can do, using the default listbox behavior. Focus will always move to
the matching value in the 1st column.

You might be able to code something in the KeyPress event to move to the
entry in the 2nd column (I've never tried it).

Or you could create a combo box that lets the user choose from a predefined
list of sorting options, and update the listbox rowsource with a new
rowsource, ie:

control: comboBox
columns: 1
RowsourceType: ValueList
RowSource: Title then Author; Author then Title; Year then Title then Author

In the AfterUpdate event of the combobox, add code like this:

if me.comboBox = "Title then Author" then me.listBox.Rowsource = "SELECT
Title, Author FROM Tables ORDER BY Title, Author;"

elseif me.comboBox = "Author then Title" then me.listBox.Rowsource = "SELECT
Author, Title FROM Tables ORDER BY Author, Title;"

elseif me.comboBox = "Year then Title then Author" then me.listBox.Rowsource
= "SELECT PublicationYear, Title, Author FROM Tables ORDER BY
PublicationYear, Title, Author;"
endif

You'll have to futz around with column counts, widths, etc.

In the end, you'll probably be better off creating separate combo or list
boxes for each field you want to search.

"Mike Top" <mi******@rogers.com> wrote in message
news:ec**************************@posting.google.c om...
I want a listbox to position to a letter provided by the user.
Normally, when the user keys a letter, the listbox positions
automatically to the first entry starting with that letter in the
first column.

I want to allow the user to select the column to be searched.

For eaxample, assume a list box that looks like this:

____________________________
| Title | Author |
|----------|----------------|
| Oklahoma | Hammerstein, O |
| Hamlet | Shakespeare, W |
.
.

Now, assume the listbox is sorted on the second column (Author), but
the column sequence stays as is. If the user keys a "S", I want the
list to position on the second entry.

Nov 12 '05 #2
On 5 Jan 2004 19:39:11 -0800, mi******@rogers.com (Mike Top) wrote:

You "position a listbox" by setting the Value property.
I did this test by creating a new form in the Northwind sample
application. I set the Rowsource to:
SELECT [Employees].[EmployeeID], [Employees].[FirstName],
[Employees].[LastName] FROM Employees ORDER BY [LastName];
and the ColumnWidths to:
0";1";1"
Then it's just a matter of finding out which value to select:
Private Sub List0_KeyDown(KeyCode As Integer, Shift As Integer)
List0.Value = DLookup("EmployeeID", "Employees", "LastName LIKE '"
& Chr$(KeyCode) & "*'")
KeyCode = 0 ' Cancel the event (otherwise a FirstName would be
selected)
End Sub

Note that it would have been better if in the KeyDown event I had used
the exact same sql statement as RowSource is using. I leave that for
you to implement.

-Tom.
I want a listbox to position to a letter provided by the user.
Normally, when the user keys a letter, the listbox positions
automatically to the first entry starting with that letter in the
first column.

I want to allow the user to select the column to be searched.

For eaxample, assume a list box that looks like this:

____________________________
| Title | Author |
|----------|----------------|
| Oklahoma | Hammerstein, O |
| Hamlet | Shakespeare, W |
.
.

Now, assume the listbox is sorted on the second column (Author), but
the column sequence stays as is. If the user keys a "S", I want the
list to position on the second entry.


Nov 12 '05 #3
Hi, Mike:

You can add an option box with radio buttons, the options being sort by title
or sort by author; then the afterupdate of the option box changes the rowsource
of the listbox. Pretty simple to execute and gives the user the option to
search on either field.

HTH

Jan
I want a listbox to position to a letter provided by the user.
Normally, when the user keys a letter, the listbox positions
automatically to the first entry starting with that letter in the
first column.

I want to allow the user to select the column to be searched.

For eaxample, assume a list box that looks like this:

____________________________
| Title | Author |
|----------|----------------|
| Oklahoma | Hammerstein, O |
| Hamlet | Shakespeare, W |
.
.

Now, assume the listbox is sorted on the second column (Author), but
the column sequence stays as is. If the user keys a "S", I want the
list to position on the second entry.


Jan Stempel
Stempel Consulting
Nov 12 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Bryan R. Meyer | last post by:
Hello Everyone, The problem of browser resizing has become an issue for me. While redesigning my webpage, I set the left and right margins to be auto so that my content would be centered. ...
4
by: Jane Withnolastname | last post by:
I am trying to re-work an old site by replacing the html with css. On the main page, I have a logo image which I needed centred on the initial screen. I found the solution here:...
14
by: Harlan Messinger | last post by:
What am I not understanding about the definition of { position: absolute; }? "The box's position (and possibly size) is specified with the 'left', 'right', 'top', and 'bottom' properties. These...
6
by: rajek | last post by:
I posted a similar question yesterday, but didn't get an answer that resolved the issue. (Thanks to those who tried though.) The background: I've read in books and online that if you have one...
11
by: NS | last post by:
I am relativly new to css positioning and have a question regarding the display of a DHTML pop-up Here is the basic HTML I am using: <html> <head> <script language="JavaScript"> <!--
17
by: amber | last post by:
Hello. Can someone tell me what I may be doing wrong here? I'm using the code (lboxRP is a listbox): Dim newRPindex As Integer newRPindex = Me.lboxRP.FindString(RP)...
1
by: Charles Harrison Caudill | last post by:
with tables there is a clean and algorithmic way to organize things, but with css which is, once you get it working, much cleaner, I have to tweak and patch and hope and pray and curse before...
6
by: Chris Leuty | last post by:
I am populating a multiselect Listbox from a dataset, with the content of the listbox filled by one table, and the selections determined from another table. So far, I have been keeping the dataset...
6
by: Mark | last post by:
hi, i'm trying to position something in the top right corner of a container, but i can't seem to figure out how to get it working. here's the html <div class='thumb'><a href='image.jpg'><img...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.