Results 1 to 14 of 14
  1. #1
    tazawoo2006 is offline Advanced Beginner
    Windows 11 Access 2021
    Join Date
    Apr 2025
    Posts
    40

    Query question

    I have combo boxes set up and work on all my forms. I am getting text data instead of the ID which is what i want. But when I create a query I get the ID and not the text that I want. What Am I doing wrong?

  2. #2
    Micron is offline Very Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,424
    Include the text field as well as the ID field in your query. A form or report doesn't need to include the id field, but it's often a good idea to include it but not show it. The user seldom needs to see the id data. If that doesn't help, maybe post the query sql, but we'll need to be able to relate that to the form fields.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  3. #3
    Join Date
    Apr 2017
    Posts
    1,792
    Let's assume you have a tables like
    tblSomeTable: SomeTableID, Field1, Field2, LookupID;
    tblLookupTable: LookupID, LookupValue

    , and a form, which displays values from current record of tblSomeTable. The control linked to LookupID is a combo box with RowSource property like
    Code:
    SELECT LookupID, LookupValue FROM tblLookupTable ORDR BY 2
    , ControlSource property like LookupID, BoundColumn Propery as 1, and ColumnWidth like "0, 2.5". The value of combo box will be LookupID in tblSomeTable, but displayed is the matching value from tblLookupTable.

    Now you create a report to display data from tblSomeTable. The Source of report will be a query like
    Code:
    SELECT st.SomeTableID, st.Field1, st.Field2, lt.LookupValue FROM tblSomeTable st LEFT JOIN tblLookupTable lt ON lt.LookupID = st.LookupID ...
    As it was commented before, there is no need for users to see any ID's, so you can set the Report control linked to SomeTableID as invisible, so for user the report displays values of Field1 and Field2 from tblSomeTable, and matching LookupValue values from tblLookupTable.

  4. #4
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,568
    What Am I doing wrong?
    Sounds like you are using LookUp fields?
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  5. #5
    tazawoo2006 is offline Advanced Beginner
    Windows 11 Access 2021
    Join Date
    Apr 2025
    Posts
    40
    Quote Originally Posted by Welshgasman View Post
    Sounds like you are using LookUp fields?
    they are relational combo boxes

  6. #6
    Join Date
    Apr 2017
    Posts
    1,792
    Quote Originally Posted by tazawoo2006 View Post
    they are relational combo boxes
    What kind of relational ones?

    Are they limiting stepwise the selection of final one? I.e. there is a single lookup index in main table, and the last combo user can select is linked to it. All other combos are unbound ones. When this is case, you report source will be a query with single join (like in my example above);
    Or are every one of them based on different lookup tables, and RowSource's of every combo are updated after every selection of every combo. When this is the case, the report source will be a query with multiple joins - a join for every lookup table involved. And displaying lookup values mathcing with apropriate lookup ID's.

  7. #7
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,568
    Quote Originally Posted by tazawoo2006 View Post
    they are relational combo boxes
    No.
    You are using a Lookup Field in the table for that particular field.?
    That is the normal cause of not understanding, that you want to store the PK of a record, but see the descriptive text.

    Like the picture.
    Attached Thumbnails Attached Thumbnails Lookups.png  
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  8. #8
    Join Date
    Apr 2017
    Posts
    1,792
    Quote Originally Posted by tazawoo2006 View Post
    I have combo boxes set up and work on all my forms. I am getting text data instead of the ID which is what i want. But when I create a query I get the ID and not the text that I want. What Am I doing wrong?
    ...
    Quote Originally Posted by Welshgasman View Post
    No.
    You are using a Lookup Field in the table for that particular field.?
    Are you assuming, OP really speaks about table instead of from in opening post?

  9. #9
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,568
    No, they are speaking about the form.
    The first DB I created still has lookup fields in it, as shown in the picture.

    However if I create a query on that table I will get the ID. However I understand how it is working.
    The first pic is with Lookups. The second is without.
    Attached Thumbnails Attached Thumbnails Links text.png   Links ID.png  
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  10. #10
    Join Date
    May 2018
    Location
    Living in Scotland UK
    Posts
    1,822
    I agree with Welshgasman.
    Can you upload a copy of the database?

  11. #11
    June7's Avatar
    June7 is offline VIP
    Windows 11 Access 2021
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,772
    Quote Originally Posted by tazawoo2006 View Post
    I have combo boxes set up and work on all my forms. I am getting text data instead of the ID which is what i want. But when I create a query I get the ID and not the text that I want. What Am I doing wrong?
    So combobox displays text as it should?

    Most likely confusion is caused by using LOOKUP field in table. Something most experienced developers never do.

    Query will have to JOIN tables to retrieve text value from LOOKUP table.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  12. #12
    Micron is offline Very Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,424
    Methinks it's time to see a db copy.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  13. #13
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,568
    Methinks, it is time to get some response from the O/P ?
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  14. #14
    tazawoo2006 is offline Advanced Beginner
    Windows 11 Access 2021
    Join Date
    Apr 2025
    Posts
    40
    Sorry folks I didn't bail. I was on the road all day yesterday traveling. I will go through all post today after my appointments and see if I can get it solved.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 6
    Last Post: 12-14-2024, 10:15 PM
  2. Replies: 1
    Last Post: 05-17-2017, 01:21 AM
  3. Replies: 1
    Last Post: 03-05-2016, 05:22 AM
  4. Query of a Query Question
    By krisN in forum Queries
    Replies: 2
    Last Post: 01-30-2014, 11:33 AM
  5. Replies: 4
    Last Post: 08-25-2012, 07:19 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums