Results 1 to 3 of 3
  1. #1
    Join Date
    Jan 2009

    Unanswered: How to include table name in query field name

    Is there a way to have Access 2003 automatically include the table name in the query field name when building a select query?

    I'm building a db that will have users with only basic Access knowledge building select queries. They want to have unique field names in the query but many of the table fields have the same names (not linked fields). I don't want to have them have to rename the query fields each time. I could add a table identifier to the field names of the tables but this makes long field names.


  2. #2
    Join Date
    Nov 2004
    out on a limb
    Provided Answers: 59
    you need the table name if there are columns with the same name in more than one table, so that JET explicitly knows which column to retrieve
    you will always need the table names in the from statement AND any JOIN (or where clauses where you specify the realtionship in the query).

    however I don't see this as too serious a problem as most of the data is available if you query the tabledefs objects.... that should provide you with the information you need, and also include the tables.
    I'd rather be riding on the Tiger 800 or the Norton

  3. #3
    Join Date
    Apr 2002
    Toronto, Canada
    healdem, i think he means that he wants the query to automatically provide aliases for similarly-named columns

    so instead of --
    SELECT foo.thisname
         , foo.thatname
         , bar.thisname
         , bar.thatname
      FROM ...
    which Access clearly has no problem creating, he'd like something like this --
    SELECT foo.thisname AS foo_thisname
         , foo.thatname AS foo_thatname
         , bar.thisname AS bar_thisname
         , bar.thatname AS bar_thatname
      FROM ...
    dj, the best way to handle this is to create a stored query which pre-joins the tables (in effect, like a view in any other database system) -- the users can then apply any WHERE clauses they want to the query when they select from it | @rudydotca
    Buy my SitePoint book: Simply SQL

Posting Permissions

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