Results 1 to 6 of 6
  1. #1
    cebrower is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2018
    Location
    Spring Lake, MI
    Posts
    110

    Exporting to Excel

    I'm trying to export some fields to an Excel spreadsheet from a table using a query. The table contains some date fields formatted in an unusual manner. The Birthday field is formatted to show the month and day. The DateJoined field displays the month and year. The resulting spreadsheet displays these fields as unformatted numbers. For the Birthday, instead of 10/25 it displays 1025. For the date joined, instead of 8/1993 it displays 81993. Is there a way to format these fields so they show up as properly formatted date fields in the resulting spreadsheet?



    In the table the Birthday field is defined as date/time, format m/d, mask ##/##. The DateJoined field is defined as date/time, format m/yyyy, mask ##/####.

    The VBA code for exporting is:

    varName = "c:\Members XL\Members.xls"
    DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "qryMembers2", varName

    Any help is appreciated.

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    Have you tried using the Format() function in the query?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    cebrower is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2018
    Location
    Spring Lake, MI
    Posts
    110
    Thanks pbaldy. Format() does the job. I just had to experiment with the mask. In the query, Birthday, for example, is BDay: Format([Birthday], "mm/dd").

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    Happy to help!

  5. #5
    cebrower is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2018
    Location
    Spring Lake, MI
    Posts
    110
    Still having a problem exporting to Excel. For example, in my query the [Birthday] field is defined BDay: Format(DateValue([Birthday]), "m/d"). In the resulting spreadsheet it looks correct, but it is formatted "General" instead of as a date even though [Birthday] is a Date/Time field in the underlying table. Is there a way to make [Birthday] come through as a date in the spreadsheet?

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    Yes, the Format() function returns a string. I suspect you'll need to let Access export the date and then use Excel automation to format the value as desired.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Exporting to Excel
    By JoeM in forum Import/Export Data
    Replies: 15
    Last Post: 09-15-2017, 08:56 AM
  2. Replies: 10
    Last Post: 12-28-2012, 02:06 PM
  3. Exporting to excel
    By Ray67 in forum Import/Export Data
    Replies: 8
    Last Post: 07-26-2012, 10:24 AM
  4. Exporting to Excel
    By TheDeceived in forum Programming
    Replies: 0
    Last Post: 11-15-2010, 08:56 AM
  5. Exporting to Excel
    By DreamOn in forum Import/Export Data
    Replies: 1
    Last Post: 05-23-2010, 10:27 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