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
11 11777 MMcCarthy 14,534
Recognized Expert Moderator MVP
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. -
SELECT CASE comboboxName
-
-
Case "item1"
-
Me.listboxName.ColumnCount = 5
-
-
Case "item2"
-
Me.listboxName.ColumnCount = 10
-
-
Case "item3"
-
Me.listboxName.ColumnCount = 2
-
-
End SELECT
-
-
Me.listboxName.Requery
-
-
You can also change column widths in this manner if required.
Mary
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. -
SELECT CASE comboboxName
-
-
Case "item1"
-
Me.listboxName.ColumnCount = 5
-
-
Case "item2"
-
Me.listboxName.ColumnCount = 10
-
-
Case "item3"
-
Me.listboxName.ColumnCount = 2
-
-
End SELECT
-
-
Me.listboxName.Requery
-
-
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
MMcCarthy 14,534
Recognized Expert Moderator MVP
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
NeoPa 32,584
Recognized Expert Moderator MVP
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.
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.
MMcCarthy 14,534
Recognized Expert Moderator MVP
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: -
SELECT * FROM TableName
-
WHERE NetworkID=[Forms]![FormName]![ComboboxName]
-
Now in the after update event of the combo box you will need the following code.
Mary
NeoPa 32,584
Recognized Expert Moderator MVP
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.
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: -
SELECT * FROM TableName
-
WHERE NetworkID=[Forms]![FormName]![ComboboxName]
-
Now in the after update event of the combo box you will need the following code.
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
NeoPa 32,584
Recognized Expert Moderator MVP
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 :(.
Sign in to post your reply or Sign up for a free account.
Similar topics |
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 the user selects
shirts another combo box called 'size' would contain sizes in relation
to shirts (ie. chest/neck size). the same would occur for trousers and
hats. when the user selects an option in the garment combo box, the
options available...
|
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 add new
textbox if there's a new employee.
What i actually want is the report do not require the user to change
anything before running the report. The report will check the total
num of col and create the exact number of textbox on the report.I...
|
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 the where clause of a sql
string to send to SQL 2000 for a data set.
Currenly I check each control with an IF statement to determine if something
is filled in. If there is I begin building the where clause. Below is what
I have done (and it...
|
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 size of a thumbnail and set the sizemode
to Stretch -- I get one thumbnail. I want to retrieve all the picture files
(jpg, bmp) in a directory into an array list and then display this list as
thumbnails on my form dynamically. So my question is...
|
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, input box for units of service, description of the service and each row has its own dropdown list of unit fees that apply.
Each dynamically created row will return 3 values fee1_choice, fee1_unit and fee1_money.
Note The above informaton is...
| |
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 able to convert it to
a datacontrol field. Below is a portion of my current code behind. By
the way I tried doing dynamic templates and was not able to get it to
work. Please help, this is driving me nuts.
Thanks
|
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 show - text boxes, input boxes, buttons,
hyperlinks ie the usual.
The data is not obtained directly from a database.
|
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. Making a selection from list/box A (Qtr) selects a fiscal quarter, which then refreshes the values in list/box B (Mth), which shows the 3 months in that fiscal quarter, which then refreshes the values in list/box C (MthDate), which returns the date...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
| |
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |