PDA

View Full Version : Only display a query's values in a listbox with the same name



jcutler
07-05-2021, 07:28 AM
In a table, named tblWorkDetails, I have two fields. The first field is named [WorkPerformed] and the second is [WorkDescription]. For [WorkPerformed] there are only three types: Adjustment, Mechanical, and Electrical. Below is an example table with real data.


[Work Performed]
[Work Description]


ADJUSTMENT
Speed - Faster


ADJUSTMENT
Speed - Slower


MECHANICAL
Fabricate


MECHANICAL
Cut Metal


ELECTRICAL
Replace Fuse












So, I created a query to consolidate the first field and the second field so it can be used in a listbox. Below is my query.

Work Type: [WorkedPerformed] & ": " & [WorkDescription] Only the checkbox show is checked for this code. So when I run this code it displays the following:
ADJUSTMENT: Speed - Faster
ADJUSTMENT: Speed - Slower
MECHANICAL: Fabricate
MECHANICAL: Cut Metal
ELECTRICAL: Replace Fuse

On a form, I want to have three listboxes with a label that corresponds with each of the items in the worked performed. So I would have listboxes named ADJUSTMENT, MECHANICAL, and ELECTRICAL. Each box should only contain items that only corresponds to their name. So listbox that is named Electrical would only show items that pertain to Electrical. This would need to apply the other two listboxes.

It would seem to me that I would have to "unquery" the items that are in the listbox just so I can get the values only for that record that have the field name of the listbox.

Is what I am wanting to do, even possible. It may sound simple, but to me it is not. Any help would be greatly appreciated. Thank you.

Gasman
07-05-2021, 07:36 AM
You would use criteria for Work Performed to populate each listbox.
That criteria would be each of your three words you mention.

OBP
07-05-2021, 11:16 AM
:thumb

jcutler
07-06-2021, 01:01 AM
Thank you Gasman, I am still new to Access. Would you mind to give an example please and thank you.

Gasman
07-06-2021, 01:36 AM
It is just a simple WHERE clause

WHERE YourFieldName = "ADJUSTMENT"

and the same with the other categories.