Results 1 to 5 of 5
  1. #1
    Join Date
    Feb 2009
    Posts
    3

    Unanswered: Finding the table name of each field in a query

    I have a query consisting of several fields from several tables. It is no problem to populate a combo box with the field names from the query (I use the vba code "For each tablefield in recordset.fields" etc), but how can I populate the combo box with all table names from the query? I know how to find ALL tables in the database, but how can I find only the tables included in my query? Thanks in advance!

  2. #2
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Not easily. Access does not expose meta data terribly well.

    There might be a point of less resistance. How come you want to populate a combo with a list of table names in a query?
    Testimonial:
    pootle flump
    ur codings are working excelent.

  3. #3
    Join Date
    Feb 2009
    Posts
    3
    Among the tables in my query, there are 3 tables with almost identical field names. I am going to use the combo box to have the users choose which field they want to search, and with the similar field names they get confused. Therefore, I want to display the table name in addition to the field name to avoid confusion.

  4. #4
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    You know you can alias column names?
    Code:
    SELECT tab_1.col_1 AS tab_1_col_1, tab_2.col_1 AS tab_2_col_1
    FROM ....
    Testimonial:
    pootle flump
    ur codings are working excelent.

  5. #5
    Join Date
    Feb 2009
    Posts
    3
    Yes, but won't that take very long time to write when I have many columns in my query (and maybe need to edit my query every once in a while)? But anyway, what I need is that when I add a column to the combo box, I need it to add which table (table name) the column comes from. How do I do that?

Posting Permissions

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