control source and listbox values

Rasberry

Board Regular
Joined
Aug 11, 2002
Messages
201
Office Version
  1. 365
My listbox created from a query works without me defining a "control source". Do I need to define a control source? Secondly, when a user makes a selection from my listbox, I want the selection to refer to a different field (tied to that record) and that field will be the "criteria" for additional queries. How do I tell populate the "criteria" via a selection from a listbox and its associated field?
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
If you don't want a control source don't use one.

If youwant to use the value selected in the combobox as the criteria for a field in a query this is the general syntax:

Forms![YourFormName]![YourComboboBoxName]
 
Upvote 0
This looks like it should work, but the query is not recognizing the selection I've made probably because the selection I've made needs to actually refer to another field and I don't know how to do that.
 
Upvote 0
What do you mean exactly?

What field is used for the listbox's RowSource and what field is needed for the query?

How are the 2 fields connected?
 
Upvote 0
The field in the RowSource is "Portfolio", the field I want to use in the criteria is "Fund Name". These fields are connected in a table.
 
Upvote 0
So you have a list of portfolios in the listbox but want to use the fund associated with the selected portfolio in the query?

Or is it vice versa?
 
Upvote 0
Yes, I have a list of portfolios listed in the listbox and want to use the associated fund for the criteria.
 
Upvote 0
So how are the 2 associated/connected/linked/friends?

Are they just 2 fields in the same table?

If they are just change the RowSource to include the Fund Name field using a query:

SELECT Portfolio, FundName
FROM tblPortfolios

Then set the listbox's ColumnCount to 2, BoundColumn to 1 and ColumnWidths to 100;0.

The column width of the 2nd column is 0 to hide the FundName column.

You can change that if you want it to be visible.

That should be it.

When a Portfolio is selected the value returned from the listbox should be the FundName of the selected Portfolio.
 
Upvote 0
Thanks so much for your help. Still can't get it to work. It is not recognizing my criteria. Maybe the selection in my listbox on the form is not being recognized as a selection.
 
Upvote 0

Forum statistics

Threads
1,224,564
Messages
6,179,543
Members
452,924
Latest member
JackiG

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top