Adjustable Listbox

  • Thread starter Thread starter Hoardling via AccessMonster.com
  • Start date Start date
H

Hoardling via AccessMonster.com

I am looking at creating an adjustable listbox. What this means if I have a
small amount of data in the listbox I don't want a large white space after
the data. When the data starts filling in then the listbox will grow. At
some point the listbox will reach a max size, in which the scroll bars will
be used afterwards. I set the size, Height. Any ideas or thoughts on this?
I know the white space isn't really a big deal, but I am going for looks here.
 
You can adjust the Height property of the List Box. The problem is, it is
not an exact science. It will take some experimenting to get the value
correct. I would suggest a value per row approach. Use the control's
ListCount property to determine how many rows it has. The example below
assumes the maximum number of rows is 12.

With Me.MyListBox
If .ListCount > 12 Then
.Height = 2700
Else
.Height = .ListCount * 270
End If
End With


Forms!frmclientsearch!lstclient.height = 270 *
forms!frmclientsearch!lstclient.listcount
 
Thanks for the information. I will try it.
You can adjust the Height property of the List Box. The problem is, it is
not an exact science. It will take some experimenting to get the value
correct. I would suggest a value per row approach. Use the control's
ListCount property to determine how many rows it has. The example below
assumes the maximum number of rows is 12.

With Me.MyListBox
If .ListCount > 12 Then
.Height = 2700
Else
.Height = .ListCount * 270
End If
End With

Forms!frmclientsearch!lstclient.height = 270 *
forms!frmclientsearch!lstclient.listcount
 
Back
Top