Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

transferspreadsheet sending all data as text

Posted on 2006-11-28
Last Modified: 2012-06-22
I'm using the transferspreadsheet to send the results of a query to an excel spreadsheet. It works, but, all the data arrives as text (like 'test or '123). I have most of the query fields set to Standard or Percent (in the "field properties") and they look fine when I view the query results or copy/paste to excel.

Any way to get around this?
Question by:avoorheis
  • 4
  • 4
  • 2
LVL 38

Expert Comment

ID: 18031541
Need to determine the cause first.  Here are some possibilities that you should check out.

1. Nulls are being inluded in exported data, interpreted as text.......need to wrap with nz function.
2. Exporting a lookup field (generally seen as a combo box), which stores a value (hidden column), but displays text.  Need to make stored value visible by changing 0 width to non-zero.

Author Comment

ID: 18032900
thanks puppydogbuddy,
I tried another pass and limited my query to one record that had data in each field, still the same. Not sure about the lookup field though. I don't have any combo boxes in the query.

While I was setting this up earlier, I copied the data from the query to a table (query is kind of slow) and it was working fine using the table as the source. The only thing I could think of is that I had the that format set up as I wanted...but, after changing the field properties to the same, I guess that wasn't the problem.

still stumped
LVL 38

Expert Comment

ID: 18033731
Hi avoorheis,
Ok ......look at your syntax for the transferspreadsheet command.   It should look something like the example below.  How does your syntax compare?  

Syntax:                                     <1>                     <2>                <3>          <4>           <5>          
DoCmd.TransferSpreadsheet [transfertype][, spreadsheettype], tablename, filename[, hasfieldnames]

DoCmd.TransferSpreadsheet acExport, 8, "Query1", "C:\SomeFile.xls", True
                                                ^       ^       ^                    ^               ^        
                                               <1>   <2>  <3>                <4>           <5>  

1. Getting back to the lookup column, you might not know it is a combo box until you actually tab into that field.  If you tab in and the drop arrow appears....then the column is a lookup column.
2. also, make sure the column sequence of the export query matches the column sequence of the excel spreadsheet, and that the column names in the excel SS match the field names in the export file.
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.


Author Comment

ID: 18033793
   DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "qryPCPrePostCompare", stPathTemp & stFileName
I'm just creating a new spreadsheet...but, I think I'm missing something in your #2, there aren't any column names in the spreadsheet. There are no lookup columns.
LVL 38

Expert Comment

ID: 18034565
From Microsoft Access On-line Help for the transfer spreadsheet method:

Has Field Names Argument:

When you export Microsoft Access table or select query data to a spreadsheet, the field names are inserted into the first row of the spreadsheet no matter what you enter for this argument.

This could be the key to solving your problem....why aren't the field names showing up???  What are the column names in your query?

Author Comment

ID: 18037995
oh, yes the column names do show up. I was thinking of something else.
LVL 38

Accepted Solution

puppydogbuddy earned 250 total points
ID: 18043064
I seem to recall something somewhere that said percent format is exported as text due to the formatting. Try putting the percent column in decimal format, and export it in decimal format and see if it shows as numeric.  You can always convert back to percent format on the excel side.

if for some reason the above does not help, you should try the following vba routine copyFromRecordset in lieu of he transferSpreadsheet method.


let me know what happened.
LVL 74

Assisted Solution

by:Jeffrey Coachman
Jeffrey Coachman earned 250 total points
ID: 18090139

<Any way to get around this?>

First of all, make sure that the Data Type of your number fields are, in fact, *NUMBER*!

(In a Table, you can specify both a Price and a Quantity field's Data Type as Text.)

Believe it or not, you can still calculate the correct Total Price ([Price]*[Quantity]) in a query!!!

Stranger still, is that when the results of this query are Exported to Excel, the Total Price Field will be a number (No leading ' ) and the Price and Quantity Fields will still be text!!! (They WILL have the Leading ' )

If this is the case, simply change the datatype of the offending fields to "Number".

Hope this helps

Jeffrey Coachman

LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 18090150
What I mean is that, in the original (source) *TABLE*, make sure the Data Types of your number fields, are in fact NUMBER.

Good luck


Author Comment

ID: 18159709
It will be a while before I get back to working on this one, so, I'm going to split the points as you both gave me some good info. I'll post another question if I still have problems when I do work on this again.


Featured Post

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Flowing down data to other tables 13 32
MS Access 2012, Split Form 2 39
how to format one of my field to percent with precision of two? 3 18
90 days before current date 12 30
In the previous article, Using a Critera Form to Filter Records (http://www.experts-exchange.com/A_6069.html), the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question