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

Combobox and list box selection

106 100+
I have combo box which displays col1 from a table1, I have a button "OK" next to it.
I also have a listbox which I want it to displays other information (col2) from table1 for a particular records.
Note: table one has two column only, both are the primary keys (there are duplicate values).

questions are:
1- How can I make the OK button to displays records in the list box for the selected item from combobox?
2- How can I make the List box to diplay nothing when I open the database (default to "")?
3- Is there a way to hide the list box, once the user make a selection form combo box and hit the OK button than the list box appear with the relavent records?

Any input is valued
thanks
Nov 20 '06 #1
12 7875
NeoPa
32,556 Expert Mod 16PB
1. Add code to change the 'ControlSorce' property.
2. Set ListBox.ListIndex to -1 (I think)
3. Set the .Visible property - as in your other post.
Nov 20 '06 #2
tara99
106 100+
1. Add code to change the 'ControlSorce' property.
2. Set ListBox.ListIndex to -1 (I think)
3. Set the .Visible property - as in your other post.
NeoPa

I need more clarification please.
Nov 20 '06 #3
NeoPa
32,556 Expert Mod 16PB
How far have you got so far with your attempts Tara?
Nov 20 '06 #4
tara99
106 100+
How far have you got so far with your attempts Tara?
Well my combo box is working meaning it does show column one of table1.
the list box that i have for diplaying the records for selected item from combo box is fine.

I have folowwing code in the rowsource of my list box
Expand|Select|Wrap|Line Numbers
  1.  SELECT CostCentres.CostCentre, CostCentres.CC_NAME FROM CostCentres INNER JOIN CostCentreSecurity ON CostCentres.CostCentre=CostCentreSecurity.CostCentre WHERE (((CostCentreSecurity.NetworkID)=forms!Form1!NetworkID)); 
Notte: NetwprkID is the the name of my combobox

When I open the form both the combo box and the list box is empty which is good.
Then when I select an item from the combo box the list box doesn’t show anything unless I go change to design mode and come back to view mode then I am able to see information available for the item in list box.

What I want is that when I hit the button it show the details in the list box, it doesn’t do that at the moment.

I hope it is clear
thanks
Nov 20 '06 #5
MMcCarthy
14,534 Expert Mod 8TB
Add one line of code to after update event of combobox

Me.ListboxName.Requery


Well my combo box is working meaning it does show column one of table1.
the list box that i have for diplaying the records for selected item from combo box is fine.

I have folowwing code in the rowsource of my list box
Expand|Select|Wrap|Line Numbers
  1.  SELECT CostCentres.CostCentre, CostCentres.CC_NAME FROM CostCentres INNER JOIN CostCentreSecurity ON CostCentres.CostCentre=CostCentreSecurity.CostCentre WHERE (((CostCentreSecurity.NetworkID)=forms!Form1!NetworkID)); 
Notte: NetwprkID is the the name of my combobox

When I open the form both the combo box and the list box is empty which is good.
Then when I select an item from the combo box the list box doesn’t show anything unless I go change to design mode and come back to view mode then I am able to see information available for the item in list box.

What I want is that when I hit the button it show the details in the list box, it doesn’t do that at the moment.

I hope it is clear
thanks
Nov 21 '06 #6
tara99
106 100+
Add one line of code to after update event of combobox

Me.ListboxName.Requery
Thanks Mary
It work for the combox now,
How about the button.
I want it to work when I hit the button???
Nov 21 '06 #7
MMcCarthy
14,534 Expert Mod 8TB
Thanks Mary
It work for the combox now,
How about the button.
I want it to work when I hit the button???
Have you tried putting the same line of code in the command button click event?
Nov 21 '06 #8
tara99
106 100+
Have you tried putting the same line of code in the command button click event?
Yes I did and it worked
I put
Expand|Select|Wrap|Line Numbers
  1. Private Sub FIND_Click()
  2. AvailabeCC.Requery
  3. End Sub
one more thing
when I change the selection before hitting the button, how can I make the listbox to don't show anything??
Nov 21 '06 #9
NeoPa
32,556 Expert Mod 16PB
Tara,

I'm glad you're making progress here.

Your point number two - It sounds like you may want either to have a ListBox showing no items at all to select from or show or to set the combobox to have no item selected.
If the former, then (we'll call your ListBox lstThis) :
Expand|Select|Wrap|Line Numbers
  1. lstThis.RowSource=""
If the latter, then (We'll call your ComboBox cboThis) :

Well...
It seems I don't know :(
I tried to find it in my help but it has bugs I'm afraid (Access 2003 seems lots worse than previous versions or it's just mucked up on my home PC :( )
I hope someone else has found a technique (I'm sure I've done it before but I can't find it atm - I'm afraid).
Nov 21 '06 #10
MMcCarthy
14,534 Expert Mod 8TB
Tara,

I'm glad you're making progress here.

Your point number two - It sounds like you may want either to have a ListBox showing no items at all to select from or show or to set the combobox to have no item selected.
If the former, then (we'll call your ListBox lstThis) :
Expand|Select|Wrap|Line Numbers
  1. lstThis.RowSource=""
If the latter, then (We'll call your ComboBox cboThis) :

Well...
It seems I don't know :(
I tried to find it in my help but it has bugs I'm afraid (Access 2003 seems lots worse than previous versions or it's just mucked up on my home PC :( )
I hope someone else has found a technique (I'm sure I've done it before but I can't find it atm - I'm afraid).
Expand|Select|Wrap|Line Numbers
  1. lstThis = Null
should work
Nov 21 '06 #11
tara99
106 100+
Tara,

I'm glad you're making progress here.

Your point number two - It sounds like you may want either to have a ListBox showing no items at all to select from or show or to set the combobox to have no item selected.
If the former, then (we'll call your ListBox lstThis) :
Expand|Select|Wrap|Line Numbers
  1. lstThis.RowSource=""
If the latter, then (We'll call your ComboBox cboThis) :

Well...
It seems I don't know :(
I tried to find it in my help but it has bugs I'm afraid (Access 2003 seems lots worse than previous versions or it's just mucked up on my home PC :( )
I hope someone else has found a technique (I'm sure I've done it before but I can't find it atm - I'm afraid).
Hi NeoPa
If you are talking about the (2- How can I make the List box to diplay nothing when I open the database (default to "")?
) point2, I believe it is fine, I havn't write any code for it and yet it works meaning that when I open the form both the list and combo box is blank.
Point 1 is also working thanks to mary.

Now the problem that I have now is that when I want to change the selection from the combo box before hitting the button I want the list box to go blank.
the other question I have is
3- Is there a way to hide the list box, once the user make a selection form combo box and hit the OK button than the list box appear with the relavent records?

Thanks
Nov 22 '06 #12
MMcCarthy
14,534 Expert Mod 8TB
To make the listbox go blank

Expand|Select|Wrap|Line Numbers
  1. Me.ListName.RowSource = ""
Try to work out where to put it based on previous instructions

To make the listbox invisible

Expand|Select|Wrap|Line Numbers
  1. Me.ListName.Visible = False
Remember to make it visible again in the Form Current, From Open or maybe Form Load event.

Test these commands out until you figure out where to use them. You'll learn more by doing it yourself.

Mary



Hi NeoPa
If you are talking about the (2- How can I make the List box to diplay nothing when I open the database (default to "")?
) point2, I believe it is fine, I havn't write any code for it and yet it works meaning that when I open the form both the list and combo box is blank.
Point 1 is also working thanks to mary.

Now the problem that I have now is that when I want to change the selection from the combo box before hitting the button I want the list box to go blank.
the other question I have is
3- Is there a way to hide the list box, once the user make a selection form combo box and hit the OK button than the list box appear with the relavent records?

Thanks
Nov 22 '06 #13

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

Similar topics

0
by: Susan Bricker | last post by:
The following error: "The current field must match the join key '?' in the table that seves as t the 'one' side of one-to-many relationship. Enter a record in the 'one' side table with the...
4
by: Bob & Martha Vera | last post by:
Hello, I can not get comboBoxes to display text in the drop down list. I can scroll down the invisible list and select something and it appears in the cb window, but I can not see anything...
5
by: Keith G | last post by:
I am using Visual Studio 2003. In the standard combobox control it would appear that only 1 column of data can be displayed in the list (as stipulated in the DisplayMember property). In VBA it was...
0
by: JamesW | last post by:
Hi. VS 2003 (VB.Net) I want to display data on a webForm based on what the user selects from a DropDownList. So, for example, if the user selects customer name from the DDL I want the...
2
by: gleadams | last post by:
I have databound a Windows form ComboBox control to a DataSource and DataMember and it is properly showing the data as I navigate through the records. My question concerns the choices in the...
2
by: mnms | last post by:
Hi, I'm wondering if it's possible "manually" add an extra value to a combobox list. At the moment I have two fields, one "transparent" is a checkbox that lets you define a colour as...
2
by: DesCF | last post by:
I have a textbox and a combobox on a toolstrip. The user enters either an ID in the textbox or selects a name from the combobox. When the user selects a name from the combobox the textbox is...
5
BigToe
by: BigToe | last post by:
Hi folks, can anyone help me with an easy one: - access 2000 I have a combo box with client names. the client names change based on two other combo boxes which do requeries. Unfortunately, I...
0
by: SteveArmstrong | last post by:
This code is used in conjunction with an excel spreadsheet, i need to be able to remove each item from the comboBox list as the item is selected this can be in any order and if and when the last item...
1
by: Aicho | last post by:
Hi, We've recently noticed a very strange occurrence with one of our comboboxes. In that instance, it concerned a databound combobox bound to a collection of items of which some had the same...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...

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.