Consulting

Results 1 to 5 of 5

Thread: Only display a query's values in a listbox with the same name

  1. #1
    VBAX Regular
    Joined
    Mar 2014
    Posts
    18
    Location

    Only display a query's values in a listbox with the same name

    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.
    Last edited by jcutler; 07-05-2021 at 07:41 AM.

  2. #2
    VBAX Regular
    Joined
    Nov 2020
    Location
    Swansea,South Wales,UK
    Posts
    25
    Location
    You would use criteria for Work Performed to populate each listbox.
    That criteria would be each of your three words you mention.

  3. #3
    VBAX Guru
    Joined
    Mar 2005
    Posts
    3,289
    Location

  4. #4
    VBAX Regular
    Joined
    Mar 2014
    Posts
    18
    Location
    Thank you Gasman, I am still new to Access. Would you mind to give an example please and thank you.

  5. #5
    VBAX Regular
    Joined
    Nov 2020
    Location
    Swansea,South Wales,UK
    Posts
    25
    Location
    It is just a simple WHERE clause

    WHERE YourFieldName = "ADJUSTMENT"

    and the same with the other categories.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •