Results 1 to 5 of 5
  1. #1
    RyanP is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Feb 2012
    Posts
    60

    Thumbs down Exporting Query Results, Foreign Key Values and Column Headers

    Am exporting a query result to excel, but the table being queried only stores the foreign key values. So the query references the lookup table in order to export the display value. All is well.


    However the Column Header is then the Column Header/ Caption of the lookup table

    I use the lookup table for many data tables so I cannot change its field name / caption as it wouldn't be appropriate in all cases. (lookup table is Employees; the Caption is 'Full Name').

    The fields that use the lookup have various names, i.e. 'Created By' 'Reported By' 'Closed By' etc which are the captions on the data tables.

    Just using the DoCmd.OutputTo acOutputQuery function...

    What to do?!?

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,945
    Try an alias name in the query.

    Post the SQL statement of your query.
    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.

  3. #3
    RyanP is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Feb 2012
    Posts
    60
    "Try an alias name in the query" I'm a NEWB enough to have never done that...

    In a nutshell;

    "SELECT lstEmployees.[Full Name] FROM lstEmployees INNER JOIN tblReports ON lstEmployees.ID = tblReports.ReportedBy;"

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,945
    SELECT lstEmployees.[Full Name] AS ReportedBy FROM lstEmployees INNER JOIN tblReports ON lstEmployees.ID = tblReports.ReportedBy;

    That query doesn't show any fields selected from tblReports. Should it?
    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.

  5. #5
    RyanP is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Feb 2012
    Posts
    60
    SELECT * AS "Alias". Well, that was easy Bit less of a newb now I figure...

    As for the simplified query, it was only for example purposes. that particular query would only return the one field from tblReports...

    thanks!

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

Similar Threads

  1. Exporting to Excel - Column Headers
    By Xarkath in forum Access
    Replies: 2
    Last Post: 01-10-2014, 01:04 PM
  2. Replies: 10
    Last Post: 01-07-2014, 04:03 PM
  3. Exporting Query results to Excel with VBA
    By Tomlon in forum Programming
    Replies: 1
    Last Post: 01-29-2013, 09:56 PM
  4. Replies: 10
    Last Post: 05-08-2012, 09:17 AM
  5. Replies: 3
    Last Post: 03-15-2012, 02:11 PM

Tags for this Thread

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