473,396 Members | 1,860 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,396 software developers and data experts.

How to Create Dynamic List Boxes.

106 100+
I was wondering if can some help me with creating a dynamic list box.

I have a combobox with the list of items (item1, item2, item3).
item1 has 5 sub items
item2 has 10 sub items
item3 has 2 sub items

I want the size of the list box to change depending on the number of sub items available.

I hope this is clear.

Thanks
Dec 12 '06 #1
11 11694
MMcCarthy
14,534 Expert Mod 8TB
I was wondering if can some help me with creating a dynamic list box.

I have a combobox with the list of items (item1, item2, item3).
item1 has 5 sub items
item2 has 10 sub items
item3 has 2 sub items

I want the size of the list box to change depending on the number of sub items available.

I hope this is clear.

Thanks
The only way to do this is using code. In the after update event of the combo box you will need to change the listbox properties.

Expand|Select|Wrap|Line Numbers
  1. SELECT CASE comboboxName
  2.  
  3. Case "item1"
  4.    Me.listboxName.ColumnCount = 5
  5.  
  6. Case "item2"
  7.    Me.listboxName.ColumnCount = 10
  8.  
  9. Case "item3"
  10.    Me.listboxName.ColumnCount = 2
  11.  
  12. End SELECT
  13.  
  14. Me.listboxName.Requery
  15.  
  16.  
You can also change column widths in this manner if required.

Mary
Dec 12 '06 #2
tara99
106 100+
The only way to do this is using code. In the after update event of the combo box you will need to change the listbox properties.

Expand|Select|Wrap|Line Numbers
  1. SELECT CASE comboboxName
  2.  
  3. Case "item1"
  4.    Me.listboxName.ColumnCount = 5
  5.  
  6. Case "item2"
  7.    Me.listboxName.ColumnCount = 10
  8.  
  9. Case "item3"
  10.    Me.listboxName.ColumnCount = 2
  11.  
  12. End SELECT
  13.  
  14. Me.listboxName.Requery
  15.  
  16.  
You can also change column widths in this manner if required.

Mary
Hi Mary
The 3 items was an example, I have maximum of almost 15000 items??
I won't know how many will be there for each selection.

Obviously I won't be having list box as big as to 15000 items (need to scroll down the list), I want to be able to specify the maximum size and also if there is only 3 item then I want the list box to be as big as that 3 items.
Does this make sense??

Thanks
Dec 12 '06 #3
MMcCarthy
14,534 Expert Mod 8TB
Hi Mary
The 3 items was an example, I have maximum of almost 15000 items??
I won't know how many will be there for each selection.

Obviously I won't be having list box as big as to 15000 items (need to scroll down the list), I want to be able to specify the maximum size and also if there is only 3 item then I want the list box to be as big as that 3 items.
Does this make sense??

Thanks
Tara

I need a lot more information. Where are these 15000 items being drawn from, table or query? Where are the sub items being drawn from? How are the distinctions made as to what belongs with an item?

Mary
Dec 12 '06 #4
NeoPa
32,556 Expert Mod 16PB
Tara,

Just to be clear.
Do you mean that you have differing numbers of columns required for different records in your ComboBox?
Or maybe you select different sets of records within the overall dataset (Table or results from a query) depending on something else not yet stated?
You see, the answer depends on what you mean in the question. We can help more when we understand the question better. Sometimes it may seem we ask detailed questions just to be difficult ;), but really these 'details' can make it so much easier to answer a question properly.
Dec 12 '06 #5
tara99
106 100+
Tara

I need a lot more information. Where are these 15000 items being drawn from, table or query? Where are the sub items being drawn from? How are the distinctions made as to what belongs with an item?

Mary
OK
I have a combo box with displays list of available NetworkID from a table called Security (This table has few field, I have just queried one field and that is NetworkID).

Then I have created a list box which shows the other field based on the NetworkID selection (I have used query to display the list box item).

In the security table I NetworkID that have access to one item, or 5 item, or 20 or even 15000.

Basically when user selects a NetworkID the list of item that this NetworkId have access t will be displayed.

So I thought it would be best to have a dynamic list box. So I can set the maximum number of item that it can display let say 15.
If the selected NetworkID have access to 2 item then the list box will be as small as 2 items, if the selected NetworkID have access to 30 item than it display all but the user will need to scroll down to see the rest.

Does this make sense??
Let me know if it is still not clear.
Dec 13 '06 #6
MMcCarthy
14,534 Expert Mod 8TB
OK
I have a combo box with displays list of available NetworkID from a table called Security (This table has few field, I have just queried one field and that is NetworkID).

Then I have created a list box which shows the other field based on the NetworkID selection (I have used query to display the list box item).

In the security table I NetworkID that have access to one item, or 5 item, or 20 or even 15000.

Basically when user selects a NetworkID the list of item that this NetworkId have access t will be displayed.

So I thought it would be best to have a dynamic list box. So I can set the maximum number of item that it can display let say 15.
If the selected NetworkID have access to 2 item then the list box will be as small as 2 items, if the selected NetworkID have access to 30 item than it display all but the user will need to scroll down to see the rest.

Does this make sense??
Let me know if it is still not clear.
OK Tara, that makes a lot more sense.

You want the list box to display a series of records corresponding to the NetworkID.

You need to set your list box Row Source to a query using the combo box selection in the criteria. Something like the following:

Expand|Select|Wrap|Line Numbers
  1. SELECT * FROM TableName 
  2. WHERE NetworkID=[Forms]![FormName]![ComboboxName]
  3.  
Now in the after update event of the combo box you will need the following code.

Expand|Select|Wrap|Line Numbers
  1. Me.listboxName.Requery
  2.  
Mary
Dec 13 '06 #7
NeoPa
32,556 Expert Mod 16PB
Tara,

That was a lot more helpful. I'm sorry I didn't get to reply but I couldn't get into TheScripts at all yesterday. Let us know if Mary's answer leaves you with any questions still.

-Adrian.
Dec 14 '06 #8
tara99
106 100+
OK Tara, that makes a lot more sense.

You want the list box to display a series of records corresponding to the NetworkID.

You need to set your list box Row Source to a query using the combo box selection in the criteria. Something like the following:

Expand|Select|Wrap|Line Numbers
  1. SELECT * FROM TableName 
  2. WHERE NetworkID=[Forms]![FormName]![ComboboxName]
  3.  
Now in the after update event of the combo box you will need the following code.

Expand|Select|Wrap|Line Numbers
  1. Me.listboxName.Requery
  2.  
Mary
Thanks Mary and NeoPa for your inputs

I have done that part,
Sorry if I didn't ask my question properly.
I guess my question is about the listbox size, how can I make it dynamic, to change its size depending on the number of item it holds (small/ big).
Does this make sense??
Is it possible.
Thanks
Dec 18 '06 #9
NeoPa
32,556 Expert Mod 16PB
The short answer to this is that you can but it's complicated.
The properties for .Height & .Width (you're interested in .Height I suspect.) are dynamically adjustable within your VBA code.
NB. The units to supply in the code are NOT the same as you use in design view necessarily. You will need to do some experimentation to determine what to ask it to do.
What you need to do is determine the number of items in the list first (.ListCount of your ListBox control) and, using that, determine the .Height value required.
Unfortunately, the size of the form itself, while it can be set in code, doesn't seem to change its visible size on screen ever :(.
Dec 18 '06 #10
tara99
106 100+
The short answer to this is that you can but it's complicated.
The properties for .Height & .Width (you're interested in .Height I suspect.) are dynamically adjustable within your VBA code.
NB. The units to supply in the code are NOT the same as you use in design view necessarily. You will need to do some experimentation to determine what to ask it to do.
What you need to do is determine the number of items in the list first (.ListCount of your ListBox control) and, using that, determine the .Height value required.
Unfortunately, the size of the form itself, while it can be set in code, doesn't seem to change its visible size on screen ever :(.
Ok than, if that is the case I better saty with what I have now,
Thank you so much to both you Neopa and Mary for helping with my query.
Cheers
Dec 19 '06 #11
MMcCarthy
14,534 Expert Mod 8TB
Ok than, if that is the case I better saty with what I have now,
Thank you so much to both you Neopa and Mary for helping with my query.
Cheers
You're welcome Tara

Mary
Dec 20 '06 #12

Sign in to post your reply or Sign up for a free account.

Similar topics

13
by: mr_burns | last post by:
hi, is it possible to change the contents of a combo box when the contents of another are changed. for example, if i had a combo box called garments containing shirts, trousers and hats, when...
3
by: Don Lee | last post by:
Hi All, i want to create a dynamic crosstab report. The method shown in http://support.microsoft.com/default.aspx?scid=kb;en-us;328320 is not a dynamic report as it require the user to manual...
4
by: Brian Shannon | last post by:
I have 3 combo boxes and two date text boxes on a .aspx page. The user can fill in any of the 5 controls or none to filter a datagrid. I was hoping someone could explain how to efficiently build...
6
by: Rich | last post by:
Hello, I want to simulate the dynamic thumbnail display of Windows Explorer (winxp) on a form or pannel container. If I place a picture box on my container form/pannel and dimension it to the...
2
by: assgar | last post by:
Hi Developemnt on win2003 server. Final server will be linux Apache,Mysql and PHP is being used. I use 2 scripts(form and process). The form displays multiple dynamic rows with chechboxs,...
0
by: mtsylvester | last post by:
Hi All, How do I add a List Box to a dynamic Details View. I want to replace the check boxes with list boxes. If I try to simply replace the check box with a list box it complains about not being...
15
by: lxyone | last post by:
Using a flat file containing table names, fields, values whats the best way of creating html pages? I want control over the html pages ie 1. layout 2. what data to show 3. what controls to...
1
by: jmartmem | last post by:
Greetings, I have a nagging problem with client-side dynamic dependent list boxes that perhaps someone can help me troubleshoot. I have a form with a series of dynamic dependent list boxes....
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.