By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,905 Members | 2,064 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,905 IT Pros & Developers. It's quick & easy.

Combobox and list box selection

100+
P: 106
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
Share this Question
Share on Google+
12 Replies


NeoPa
Expert Mod 15k+
P: 31,492
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

100+
P: 106
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
Expert Mod 15k+
P: 31,492
How far have you got so far with your attempts Tara?
Nov 20 '06 #4

100+
P: 106
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
Expert Mod 10K+
P: 14,534
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

100+
P: 106
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
Expert Mod 10K+
P: 14,534
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

100+
P: 106
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
Expert Mod 15k+
P: 31,492
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
Expert Mod 10K+
P: 14,534
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

100+
P: 106
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
Expert Mod 10K+
P: 14,534
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

Post your reply

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