- SELECT CostCentres.CostCentre, CostCentres.CC_NAME FROM CostCentres INNER JOIN CostCentreSecurity ON CostCentres.CostCentre=CostCentreSecurity.CostCent re WHERE (((CostCentreSecurity.NetworkID)=forms!Form1!Netwo rkID));
Tags: access, box, button, col1, combo, combobox, database, displays, listbox, microsoft, mysql, oracle, selection, sql, table1
Combobox and list box selection
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).
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
Leave a comment...
- 12 Comments
- 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.#1; Fri, 04 Jan 2008 09:47:00 GMT
I need more clarification please.#2; Fri, 04 Jan 2008 09:48:00 GMT
- How far have you got so far with your attempts Tara?#3; Fri, 04 Jan 2008 09:49:00 GMT
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 boxCode: ( text )
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 doesnt 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 doesnt do that at the moment.
I hope it is clear
thanks#4; Fri, 04 Jan 2008 09:50:00 GMT
- Add one line of code to after update event of combobox
Me.ListboxName.RequeryQuote:#5; Fri, 04 Jan 2008 09:51:00 GMT
It work for the combox now,
How about the button.
I want it to work when I hit the button?#6; Fri, 04 Jan 2008 09:52:00 GMT
Have you tried putting the same line of code in the command button click event?#7; Fri, 04 Jan 2008 09:53:00 GMT
Yes I did and it worked
I putCode: ( text )one more thing
- Private Sub FIND_Click()
- End Sub
when I change the selection before hitting the button, how can I make the listbox to don't show anything??#8; Fri, 04 Jan 2008 09:54:00 GMT
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 forme