Is it possible to make a listbox occupy more than one column?

G

Guest

For speed of data entry, I want to design a form with a listbox that is big
enough to show all the possible values simultaneously (i.e. without any
vertical scrolling of the listbox). Unfortunately, there are too many values
to fit into a conventional single-column listbox. Is there a way to make a
listbox that 'spills over' into multiple columns?

David
 
D

Douglas J. Steele

David Anderson said:
For speed of data entry, I want to design a form with a listbox that is
big
enough to show all the possible values simultaneously (i.e. without any
vertical scrolling of the listbox). Unfortunately, there are too many
values
to fit into a conventional single-column listbox. Is there a way to make a
listbox that 'spills over' into multiple columns?

Not using the list box that's built into Access, and I'm not aware of any
3rd party controls that can do that and work with Access.
 
O

OldPro

For speed of data entry, I want to design a form with a listbox that is big
enough to show all the possible values simultaneously (i.e. without any
vertical scrolling of the listbox). Unfortunately, there are too many values
to fit into a conventional single-column listbox. Is there a way to make a
listbox that 'spills over' into multiple columns?

David

It is possible, but you have to build your own listbox using label
controls. Start with a new form, and put about a hundred labels on
the form. They will automatically be numbered Label1 to Label100.
Hilite them all and turn them invisible. Use code to position them
into a listbox and to fill them with data. As you fill each with
data, save the key field to the .tag property. In the Click event of
the label, put only the name of a function to call, do NOT open a code
window. For example: =LabelSelect(12 ) where 12 is the number of the
label. This will make it easy; instead of a hundred different event
procedures, there will be just one that is called from 100 different
labels. Then create the function where you would put the selection
code. You will need an array to keep track of labels, whether they
are being used or not, and you will need a function the clears the
labels.
It is a bit of work. You will have to decide if the effort is worth
it. One final warning: it may perform slowly in Access 2007, but
should run fine in other versions.
Variants: If you want to allow user input, position a textbox when the
user clicks on a label. Make sure to size the textbox to match the
label before turning it visible. Also, if you want to make a drop
down box, hilite the labels and select "Bring to Front" to insure they
won't be blocked by whatever is underneath. Some controls can't be
hidden by labels, so you will have to experiment. To clean up the
drop box when focus changes, you will need to call a cleanup procedure
from the onfocus event of the form and every other control.
Good luck!
 
A

Albert D. Kallal

Well, you could code the results.

Decide how many columns you want, and then pull the data into array,a nd
then feed the listbox via code.

There is a call back sample here:

http://www.mvps.org/access/forms/frm0049.htm

So, you can use code to control how many columns. You have to write the code
to "map" the values from the array of data (matrix of data) into multiple
columns....

not that hard to do at all....
 
D

Douglas J. Steele

But how would you know that the user selected the item from the second
column, and not from the first column? While you could probably do something
to determine the xy position of the mouse during a click or double click,
and then determine the column on which the mouse was clicked, there wouldn't
appear to be any way in which you could do multiselects.
 
O

OldPro

But how would you know that the user selected the item from the second
column, and not from the first column? While you could probably do something
to determine the xy position of the mouse during a click or double click,
and then determine the column on which the mouse was clicked, there wouldn't
appear to be any way in which you could do multiselects.

--
Doug Steele, Microsoft Access MVPhttp://I.Am/DougSteele
(no e-mails, please!)








- Show quoted text -

You would know which item was selected because you would know which
label was clicked, and the label would have the record key in its .tag
property.
 
O

OldPro

But how would you know that the user selected the item from the second
column, and not from the first column? While you could probably do something
to determine the xy position of the mouse during a click or double click,
and then determine the column on which the mouse was clicked, there wouldn't
appear to be any way in which you could do multiselects.

--
Doug Steele, Microsoft Access MVPhttp://I.Am/DougSteele
(no e-mails, please!)








- Show quoted text -

The original question was for multiple columns to show all of the
possible values of one field. If you wanted to keep track of row and
column, you can name each label something like "lblGridR1C2" and you
can pass row and column to the click function =ItemSelected(1,1).
 
D

Douglas J. Steele

My question/comment was aimed at Albert's solution.

Your use of labels would seem to suffer from the fact that labels can't be
bound (as doesn't Albert's, for that matter).
 
O

OldPro

My question/comment was aimed at Albert's solution.

Your use of labels would seem to suffer from the fact that labels can't be
bound (as doesn't Albert's, for that matter).

--
Doug Steele, Microsoft Access MVPhttp://I.Am/DougSteele
(no e-mails, please!)







- Show quoted text -

True enough. Even though bound controls are less work, I favor the
level of control that I get when I do it with code. I prefer my own
bugs to those of others. I have found limitations in the listbox, the
subform, the bound form, and the continuous form, all of which I can
get around by making my own grid out of labels and a textbox. I even
add a homemade scrollbar that works like a charm! The only caveat is
that it is too slow in Access 2007.
 
A

Albert D. Kallal

Douglas J. Steele said:
But how would you know that the user selected the item from the second
column, and not from the first column? While you could probably do
something to determine the xy position of the mouse during a click or
double click, and then determine the column on which the mouse was
clicked, there wouldn't appear to be any way in which you could do
multiselects.

Yes...I never thought of that problem!!!

You could use my idea to display data, but, if user needs selection...then
my suggestion is likely not workable due to your good point!!!

next bus stop idea!

Hum, ok...feed data to temp table...use continues form with multiple
columns. If one allows only 5 rows, then a click event could be used. (in
fact, one could write out a field in the table that gives the row
number...and then the 1-5 control could give the column number clicked on...
 
S

Stephen Lebans

Hi Albert,
I have posted code in the past to allow you to determine which column the
user is selecting.

Alternatively, there is a solution on my site that exposes the native
ListBox control Access uses internally to allow multiple columns,
checkboxes, CF, etc.
http://www.lebans.com/vb_listbox.htm
New Version 3 April 23, 2003 - MULTISELECT must be enabled for this version
to function properly.

Special Thanks to Peter Walker!

FieldList.zip is a database containing the FieldList control Access uses in
its Table Analyzer and Performance Analyzer Wizards. This control is created
directly from the ACCWIZ.DLL so no ActiveX registration problems are
incurred. ACCWIZ.DLL is automatically installed with all full installs of
Access.

This a VB like ListBox with:

1) CheckBoxes for each row

2) True Drag and Drop

3) Conditional Formatting for each Row

4) AddItem method



History

Version 2.5

Fixed bug with Small/Large font issues..

Version 2.3

Added support for Move on Double Click and Move all Selected Rows on Double
Click as well. Cleaned source code of the last remaining junk.

Version 2.2

Cleaned, commented and enhanced source code. Added support for dragging of
multiple rows.

Version 1.5

Added Dual ListBox Pick Lists with AddItem, RemoveItem and Drag and Drop.

Version 1.0

Added Calendar Sample Form.


--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
 

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