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!