Tags: access, box, button, col1, combo, combobox, database, displays, listbox, microsoft, mysql, oracle, selection, sql, table1

Combobox and list box selection

On Database » Microsoft Access

13,542 words with 12 Comments; publish: Fri, 04 Jan 2008 09:46:00 GMT; (25078.13, « »)

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

All Comments

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
    • Quote:
      === Original Words ===

      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.

      #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
    • Quote:
      === Original Words ===

      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

      Code: ( text )
      1. SELECT CostCentres.CostCentre, CostCentres.CC_NAME FROM CostCentres INNER JOIN CostCentreSecurity ON CostCentres.CostCentre=CostCentreSecurity.CostCent re WHERE (((CostCentreSecurity.NetworkID)=forms!Form1!Netwo rkID));

      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.Requery

      Quote:
      === Original Words ===

      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

      Code: ( text )
      1. SELECT CostCentres.CostCentre, CostCentres.CC_NAME FROM CostCentres INNER JOIN CostCentreSecurity ON CostCentres.CostCentre=CostCentreSecurity.CostCent re WHERE (((CostCentreSecurity.NetworkID)=forms!Form1!Netwo rkID));

      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

      #5; Fri, 04 Jan 2008 09:51:00 GMT
    • Quote:
      === Original Words ===

      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?

      #6; Fri, 04 Jan 2008 09:52:00 GMT
    • Quote:
      === Original Words ===

      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?

      #7; Fri, 04 Jan 2008 09:53:00 GMT
    • Quote:
      === Original Words ===

      Have you tried putting the same line of code in the command button click event?

      Yes I did and it worked

      I put

      Code: ( text )
      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??

      #8; Fri, 04 Jan 2008 09:54:00 GMT
    • 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 forme