Problem exporting Access report to Excel

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Whenever I try to export an Access report to Excel(Access 2002, I believe) ,
some value from my primary key column, AssetID which is Text of length 25,
are converted to a negative number. For example, the report might display
these records:
1298
10329
129 09
402 82

In the report, they are dispplayed correctly. When I export these values to
the Excel file (XLS format), the values "129 09" and "402 82" are
displayed as a negative number (eg. -39284723) while the others are exported
correctly. This only happens with values that have spaces in between them.

How come?

Thanks,
AA
 
I am able to partially reproduce your results. On my PC, the "129 09" shows up
as -646599 in the Excel spreadsheet, but the "402 82" part shows up as 402
82.....weird!

In any case, I was able to export the data directly from a table to an Excel spreadsheet
(without first using the Access report), by using a command button on a form with the code
shown below. Then all of your data exported correctly. This uses the TransferSpreadsheet
method of the DoCmd object. You can substitute a named query in place of "tblTestData".

Private Sub cmdExportData_Click()
On Error GoTo ProcError

DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "tblTestData", _
"C:\Documents and Settings\Administrator\My Documents\ExportTest.xls"

MsgBox "Data Exported", vbInformation, "Success..."

ExitProc:
Exit Sub
ProcError:
MsgBox "Error: " & Err.Number & ". " & Err.Description
Resume ExitProc
End Sub



Tom

__________________________________

<aa> wrote in message Whenever I try to export an Access report to Excel(Access 2002, I believe) ,
some value from my primary key column, AssetID which is Text of length 25,
are converted to a negative number. For example, the report might display
these records:
1298
10329
129 09
402 82

In the report, they are dispplayed correctly. When I export these values to
the Excel file (XLS format), the values "129 09" and "402 82" are
displayed as a negative number (eg. -39284723) while the others are exported
correctly. This only happens with values that have spaces in between them.

How come?

Thanks,
AA
 
Back
Top