#Value fields, while exporting from access 2000 to an excel spread

N

Netalie

While exporting from access to an excel spreadsheet,Some fileds, defined as
long text (Momo) are exported as " #Value ".

I am using a vba code:

Public Function ExportRequest(full As Boolean) As String
On Error GoTo err_Handler

'Path to save the output
Dim SourcePath, OutputDoc As String

SourcePath = Left(CurrentDb.Name, Len(CurrentDb.Name) -
Len(Dir(CurrentDb.Name)))
OutputDoc = SourcePath & "Data_Requirement.xls"


' Excel object variables
Dim AppExcel As excel.Application
Dim wbk As excel.Workbook
Dim wks As excel.Worksheet
Dim wks2 As excel.Worksheet
Dim wks3 As excel.Worksheet
'Dim wks4 As excel.Worksheet


Dim sTemplate As String
Dim sTempFile As String
Dim sOutput As String

Dim sRows As String

Dim dbs As DAO.Database
Dim rst As DAO.Recordset
Dim sSQL As String
Dim SStr As String
Dim lRecords As Long
Dim iRow As Integer
Dim iCol As Integer
Dim iFld As Integer

Const cTabTwo As Byte = 2
Const cTabOne As Byte = 1
Const cTabThree As Byte = 3
Const cTabFour As Byte = 4
Const cStartRow As Byte = 2
Const cStartColumn As Byte = 1

DoCmd.Close acForm, "frm_ExcelOutput", acSaveYes

DoCmd.Hourglass True

' set to break on all errors
Application.SetOption "Error Trapping", 0


' Create the Excel Applicaiton, Workbook and Worksheet and Database object
Set AppExcel = excel.Application
Set wbk = AppExcel.Workbooks.Add()

Set wks = AppExcel.Worksheets(cTabTwo)
Set wks2 = AppExcel.Worksheets(cTabThree)
Set wks3 = AppExcel.Worksheets(cTabOne)
'Set wks4 = AppExcel.Worksheets(cTabFour)
' appExcel.Visible = True

....
....
....
....

Set dbs = CurrentDb
Set rst = dbs.OpenRecordset(sSQL, dbOpenSnapshot)
If Not rst.BOF Then rst.MoveFirst

' For this template, the data must be placed on the 2th row, 1st column.
' (these values are set to constants for easy future modifications)
iCol = cStartColumn
iRow = cStartRow


Do Until rst.EOF
iFld = 0
lRecords = lRecords + 1

For iCol = cStartColumn To cStartColumn + (rst.Fields.Count - 1)
wks.Cells(iRow, iCol) = rst.Fields(iFld)

wks.Cells(iRow, iCol).WrapText = True
iFld = iFld + 1
Next

wks.Rows(iRow).EntireRow.AutoFit
iRow = iRow + 1
rst.MoveNext
Loop

....
....
....



Does any one have any idea how can this be solved? these are fields with a
legth less then 255.
I'm using office 2000, SP-3.

Thank you very much for the help!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top