link a combo box to a list box (1 Viewer)

MIkeD666

Registered User.
Local time
Today, 05:58
Joined
Jan 12, 2019
Messages
59
HI I am hoping you can help me. I seem to have a metal block and can’t remember how to do this.

I have a form, with a combobox (on the form header) that is linked to a table called suppliers.
The table has the suppliers Name and IDcode and other information. When the user selects a supplier by name using the combobox.

I want to get the supplier! IDcode And Link to in the list box in the main form to only show records from the table stocklist that have the same idcode.
Using the IDcode in the suppliers table to link to the IDcode in the stocklist.

I have a relationship between the tables using the supplier idcode field in the suppliers tables joined to the IDcode in the stocklist table.
But I seem to be brain dead. As I can not get the list box to link to the idcode. It’s driving me mad. Thanks in advance for any help given
mIke
 

Gasman

Enthusiastic Amateur
Local time
Today, 12:58
Joined
Sep 21, 2011
Messages
14,041
Just use the combo value as criteria for the listbox recordsource.
 

CJ_London

Super Moderator
Staff member
Local time
Today, 12:58
Joined
Feb 19, 2013
Messages
16,553
think what you are talking about is often called 'cascading combo's'

so select a supplier in your combo

the rowsource to your listbox will be something like

SELECT * FROM tblStockists WHERE supplierFK=[cboSuppliers]

in your listbox got focus event (or perhaps your combo afterupdate event put

lstStockists.Requery

change names to suit

depends on how your form is intended to work but you may also need to clear lstStockist of a value if you change supplier and you may also need to do something in the form current event for when a record refreshes
 

MIkeD666

Registered User.
Local time
Today, 05:58
Joined
Jan 12, 2019
Messages
59
think what you are talking about is often called 'cascading combo's'

so select a supplier in your combo

the rowsource to your listbox will be something like

SELECT * FROM tblStockists WHERE supplierFK=[cboSuppliers]

in your listbox got focus event (or perhaps your combo afterupdate event put

lstStockists.Requery

change names to suit

depends on how your form is intended to work but you may also need to clear lstStockist of a value if you change supplier and you may also need to do something in the form current event for when a record refreshes
Thanks. when i see it, it simple, I think lock down must be frying my brain
 

davegoodo

Member
Local time
Today, 23:58
Joined
Jan 11, 2024
Messages
42
I have a similar problem but I'm not as confident. My problem is I have a combo box: cboClarity, which is based on a query qryClarityData.
There are only 3 alternatives: "Average", "Good" or "Poor". I have a list box: txtExplainer on the same form which has explanations of what these alternatives mean. I want to select a clarity value in the combo box and have the list box display the explanation of the clarity value chosen.

When looking at the answer above I realised my list box doesn't have a RowSource, (or I couldn't find it!). Either way I'm stuck. I need to put some SQL into somewhere in the list box txtExplainer which synchronises with the ClarityID in the combo box. I'm a bit clueless on this part if you might help. I have attached a brief text note explaining some of the details.

As an aside, can the list box be set to have multi-line explanations? How could that be done?
 

Attachments

  • ComboBox Infor.txt
    535 bytes · Views: 43

bob fitz

AWF VIP
Local time
Today, 12:58
Joined
May 23, 2011
Messages
4,717
I have a similar problem but I'm not as confident. My problem is I have a combo box: cboClarity, which is based on a query qryClarityData.
There are only 3 alternatives: "Average", "Good" or "Poor". I have a list box: txtExplainer on the same form which has explanations of what these alternatives mean. I want to select a clarity value in the combo box and have the list box display the explanation of the clarity value chosen.

When looking at the answer above I realised my list box doesn't have a RowSource, (or I couldn't find it!). Either way I'm stuck. I need to put some SQL into somewhere in the list box txtExplainer which synchronises with the ClarityID in the combo box. I'm a bit clueless on this part if you might help. I have attached a brief text note explaining some of the details.

As an aside, can the list box be set to have multi-line explanations? How could that be done?
I don't think it's a good idea to add your question to a post that was solved over 3 years ago.
I have attached a brief text note explaining some of the details.
Why attach a text file? You could have written all of that here. Attaching a copy of your db would be far more useful.
IMHO it might be better to start a new thread for your inquiry.
 

davegoodo

Member
Local time
Today, 23:58
Joined
Jan 11, 2024
Messages
42
I don't think it's a good idea to add your question to a post that was solved over 3 years ago.

Why attach a text file? You could have written all of that here. Attaching a copy of your db would be far more useful.
IMHO it might be better to start a new thread for your inquiry.
Thanks for that.
Please be advised that I have re-posted my question to the Forms forum, which I should have done to begin with.
Much appreciated, apologies for any inconvenience caused. It is at the following address:

 

Gasman

Enthusiastic Amateur
Local time
Today, 12:58
Joined
Sep 21, 2011
Messages
14,041

mike60smart

Registered User.
Local time
Today, 12:58
Joined
Aug 6, 2017
Messages
1,899
I have a similar problem but I'm not as confident. My problem is I have a combo box: cboClarity, which is based on a query qryClarityData.
There are only 3 alternatives: "Average", "Good" or "Poor". I have a list box: txtExplainer on the same form which has explanations of what these alternatives mean. I want to select a clarity value in the combo box and have the list box display the explanation of the clarity value chosen.

When looking at the answer above I realised my list box doesn't have a RowSource, (or I couldn't find it!). Either way I'm stuck. I need to put some SQL into somewhere in the list box txtExplainer which synchronises with the ClarityID in the combo box. I'm a bit clueless on this part if you might help. I have attached a brief text note explaining some of the details.
here
As an aside, can the list box be set to have multi-line explanations? How could that be done?
You should explain that you received the answer from your cross posted item
here
 

mike60smart

Registered User.
Local time
Today, 12:58
Joined
Aug 6, 2017
Messages
1,899
I have a similar problem but I'm not as confident. My problem is I have a combo box: cboClarity, which is based on a query qryClarityData.
There are only 3 alternatives: "Average", "Good" or "Poor". I have a list box: txtExplainer on the same form which has explanations of what these alternatives mean. I want to select a clarity value in the combo box and have the list box display the explanation of the clarity value chosen.

When looking at the answer above I realised my list box doesn't have a RowSource, (or I couldn't find it!). Either way I'm stuck. I need to put some SQL into somewhere in the list box txtExplainer which synchronises with the ClarityID in the combo box. I'm a bit clueless on this part if you might help. I have attached a brief text note explaining some of the details.

As an aside, can the list box be set to have multi-line explanations? How could that be done?
If there are Multiple Explainers for each of the Clarity options then you need two tables to manage a 1 to Many relationship.
 

davegoodo

Member
Local time
Today, 23:58
Joined
Jan 11, 2024
Messages
42
I tried the example that C.J. posted and that was perfect. I have tried duplicating this into my database and it isn't working.
I have attached it here.
 

Attachments

  • Horse_Racing.accdb
    608 KB · Views: 25

CJ_London

Super Moderator
Staff member
Local time
Today, 12:58
Joined
Feb 19, 2013
Messages
16,553
it isn't working.
I saw two versions , the first because your combo is using a value list as the rowsource, not a table, the second uses a query but does not include the explainer field - you can hide that by setting the column width to 0
 

Users who are viewing this thread

Top Bottom