Link to home
Start Free TrialLog in
Avatar of jb702
jb702

asked on

Access Export to csv or tab Delimited.

How can i get access to export data so that when opened in excel the data of a field looks like the data that was in an access memo record.

For Example, the below text is what is saved in a record in access. The export has several columns this is just one field. I need to be able to export out the data so when opened in excel as a txt or csv file the data below stays in one field and one record. This is because this data is being imported in QuickBooks and needs to stay in one record.

Found angle stop leaking  won't turn off
Found tank to bowl leaking
Found closet ring rusted out.  Causing wax ring to fell. Leaking
Found major discoloration on ceiling at entry way.
Found ball valve in garage will not turn off water to house

Repairs

Installed new angle stop
Installed new supply line
Replaced tank to bowl gasket

This job is not complete.   This job is not complete
we are submitting a proposal for remediation and buildback.
Avatar of Jeffrey Coachman
Jeffrey Coachman
Flag of United States of America image

Line breaks are not interpreted by CSV/Tab delimited files.

To me this looks like it should be in separate tables/records anyway.

tblIssues
iID
iDate
iNotes
iReportedBy
...etc

tblSympoms
sID
iID
sText
...etc

tblRepairs
rID
iID
rText
...etc

with your data stored like this, you can concatenate these records together then insert them into your Quicken data.

Lets see if another expert can help with a solution that keeps your data in its current format.

JeffCoachman
Avatar of jb702
jb702

ASKER

i don't think your statement "Line breaks are not interpreted by CSV/Tab delimited files." is true.

If you take some data and you put in a cell in excel and where you want a line break, you press alt+enter. The save the data as a csv or tab file, the import file will import into quick books.  Hmmm. i just tried that and it works with a .csv file but not a tab file.
You could try this, which came from Dirk Goldgar original source at
MS Access 2013 truncates longtext fields to 255 characters when exporting to excel?

Sub CopyToExcel(TableOrQuery As String, WorkbookPath As String, Optional WorksheetName As String)

    Dim rs As DAO.Recordset

    ' Note: the following declarations use early binding, so they require
    ' a reference to be set to the Microsoft Excel? <version> Object Library.
    ' Late binding could be used instead.?
    Dim appExcel    As Excel.Application
    Dim wb          As Excel.Workbook
    Dim ws          As Excel.Worksheet
   
    Dim iCols       As Integer

    Set rs = CurrentDb.OpenRecordset(TableOrQuery)
   
    Set appExcel = New Excel.Application

    Set wb = appExcel.Workbooks.Add()
    Set ws = wb.Sheets(1)

    ' Create a worksheet header row from the recordset's field names.
    With rs
        For iCols = 0 To .Fields.Count - 1
            ws.Cells(1, iCols + 1).Value = .Fields(iCols).Name
        Next
    End With
    ws.Range(ws.Cells(1, 1), ws.Cells(1, rs.Fields.Count)).Font.Bold = True
   
    ' Starting on the next line of the worksheet, copy each row from the
    ' recordset to a new row in the worksheet.  Excel provides a simple
    ' method call to do this.
   
    ws.Range("A2").CopyFromRecordset rs
   
    ' Size columns to fit the data.
    ws.UsedRange.Columns.AutoFit

    ' Name the worksheet.
    If Len(WorksheetName) > 0 Then
        ws.Name = WorksheetName
    End If

    ' Save the workbook.
    wb.SaveAs WorkbookPath
   
    ' Terminate the Excel application.
    appExcel.Quit

End Sub

Open in new window


To use, paste the above code into a VB code module.  You can then run it from the immediate window by typing in

CopyToExcel("Insert name of table or query here" , "insert path and filename to output to")

for example:

CopyToExcel("MyTable", "C:\myexcelfile.xlsx")
ASKER CERTIFIED SOLUTION
Avatar of Gustav Brock
Gustav Brock
Flag of Denmark image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
... and from there if you need a csv file for Quickbooks, you can save to csv from Excel.  I don't know if Quickbooks will import Excel xls/xlsx files directlly, but use that if it's an option instead.
EDIT: sorry, leave the parenthesis out when running the Sub -- so

CopyToExcel "MyTable", "C:\myexcelfile.xlsx"
When you use the Export Icon in the Ribbon bar, check the box to preserve formatting and layout.  This will keep your linefeeds in Excel.  You can then save this export and rerun it again via code or by clicking on the Saved Exports Icon on the Ribbon.
User generated image
Ron
Avatar of jb702

ASKER

Thank you
You are welcome!

/gustav