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; (25058.59, « »)

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 former, then (we'll call your ListBox lstThis) :

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

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

      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) :

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

      Code: ( text )
      1. lstThis = Null

      should work

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

      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) :

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

      #11; Fri, 04 Jan 2008 09:57:00 GMT
    • To make the listbox go blank

      Code: ( text )
      1. Me.ListName.RowSource = ""

      Try to work out where to put it based on previous instructions

      To make the listbox invisible

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

      Quote:
      === Original Words ===

      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

      #12; Fri, 04 Jan 2008 09:58:00 GMT