Results 1 to 6 of 6
  1. #1
    icaines9517 is offline Novice
    Windows 8 Access 2007
    Join Date
    Jun 2016
    Posts
    7

    Exporting Data into Excel

    It's been awhile since I've used Microsoft Access and I'm kind of stumped on this one. I'm using Microsoft Access 2007 and after running a query I have the code to export the query results into an excel spreadsheet. However, after exporting it into the spreadsheet instead of showing the text value of my lookup columns only the numbers are showing. If possible, how can I fix this? Any help would be appreciated.

    Thanks,

  2. #2
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    instead of showing the text value of my lookup columns only the numbers are showing
    perhaps these are lookup fields in a table? If so, then the number would be exported. One of the many problems with lookup fields - see this link http://access.mvps.org/access/lookupfields.htm

    If this is not the case

    I have the code to export the query results into an excel spreadsheet
    What code would that be? there are a number of different ways of exporting....

    also please provide some example data to be exported and what it looks like in the spreadsheet

  3. #3
    Perceptus's Avatar
    Perceptus is offline Expert
    Windows 7 64bit Access 2007
    Join Date
    Nov 2012
    Location
    Knoxville, Tennessee
    Posts
    659
    Make sure the formatting of your fields in excel is set correctly. Also I dont recommend doing it the way you do. I would recommend establishing a data source in excel and connecting it to the query in the access database. you can then have this data brought into your excel sheet. Lots of options down the road after this. You can force the data to update when the excel file loads, every so often or only when you click the refresh button.

  4. #4
    icaines9517 is offline Novice
    Windows 8 Access 2007
    Join Date
    Jun 2016
    Posts
    7
    Thanks for the replies. Yeah my problem is the first point Ajax stated in which these numbers are lookup fields to another table. That article included in the link explains the reasons why I am not getting the output I want. I would like to try Perceptus method of doing this except for the fact I have no clue how to implement the method seeing I'm a bit of a novice user. Could you lead me in the right direction? Below is VBA code I have that exports the two queries and attached is my output:

    Private Sub Command10_Click()
    DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12Xml, "PO MKTG Query(NEW)", "C:\Users\ICaines\Desktop\Book1.xlsx", True
    DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12Xml, "TAN MKTG Query (NEW)", "C:\Users\ICaines\Desktop\Book1.xlsx", True
    Attached Thumbnails Attached Thumbnails Excel Output.jpg  
    Last edited by icaines9517; 06-27-2016 at 11:55 AM.

  5. #5
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    this demonstrates the pointlessness of lookup fields - strongly recommend you remove them from your table design so you can see exactly what you have.


    to get the values you require

    1. open your PO MKTG Query(NEW) query
    2. drag onto the query the tables where Dept, Status and Paid by names are stored
    3. create a link (if not already specified in your relationships) between the two fields with the numbers (i.e. as per your lookup field)
    4. then drag the names down to replace the fields with numbers.

    job done

    incidentally, using ( and ) in names is a bad idea - will come back to bite you some day. If you are worried about names not being 'right' - use the caption property in field design

  6. #6
    icaines9517 is offline Novice
    Windows 8 Access 2007
    Join Date
    Jun 2016
    Posts
    7
    Thank you for your help. I'm only having trouble with the last step (4. drag the names down to replace the fields with numbers). What exactly am I dragging down to replace my fields that are displaying numbers? The field from the table the numbers are linked to?

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

Similar Threads

  1. Help with exporting data from excel to access
    By accessrook in forum Import/Export Data
    Replies: 2
    Last Post: 01-22-2013, 12:58 AM
  2. Exporting data to excel form
    By Ben M in forum Access
    Replies: 1
    Last Post: 09-18-2012, 10:59 AM
  3. Exporting data to ms excel
    By dolovenature in forum Import/Export Data
    Replies: 1
    Last Post: 09-11-2012, 11:47 PM
  4. exporting data from access to excel
    By tariq nawaz in forum Access
    Replies: 3
    Last Post: 09-06-2012, 09:29 AM
  5. Exporting Data to Excel from a Web database
    By need_help12 in forum Import/Export Data
    Replies: 1
    Last Post: 05-16-2012, 04:59 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