Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

vbCrlf in Access VBA code for Memo Field, but Excel no carriage return

Status
Not open for further replies.

qmacg

Technical User
Aug 20, 2001
47
US
Sorry I couldn't fit everything descriptive in the subject line but here goes. I'll have the following code in VBA to include a carriage return...:
strHoldGCdata = strHoldGCdata & "<<" & vbCrLf

Now the data in the Memo field i'm adding this to in access creates a carriage return. But when I export the table to Excel, for some reason the carriage return is not reflected in the Field. Instead it has ABC||DEF in the field. I would expect it to be like this within the same field...:
ABC
DEF

I know its something simple or silly i'm just not seeing. Any help would be appreciated. Thanks.
 
wordwrap the field in excess.

Ian Mayor (UK)
Program Error
9 times out of 10 I know what I'm talking about. This must be my tenth reply.
 
sorry excel i mean

Ian Mayor (UK)
Program Error
9 times out of 10 I know what I'm talking about. This must be my tenth reply.
 
Thanks, but is there a way to code it in access vba before I export the table as an Excel spreadsheet? I really didn't want to instantiate an Excel spreadsheet and export it field by field then take the time to format the field as it's writing out row by row. Figured there was some sort of code to put in the memo field (i.e. vbCrlf).
 
What happens if you export to a CSV file and how are you doing the extract?
 
I was using the regular docmd.TransferSpreadsheet command to export the Excel file. But it looks like when I did the docmd.TransferText for the .csv you mentioned above, I was getting the word to appear on the next line of the field( when I opened the file.csv in Excel), but had a square character at the end of each line in the field. This was when I was using vbCrLf, but when I just used VbLF the character dissappeared and I got my results like so...
ABC
123
So I think the workaround for me is to just export the table that has memo Fields using docmd.TransferText, then use a specification with comma delimted and end each line in a field with VbLf, open the .csv file in Excel and then do a Save As in the Excel 97 format. The only annoyance is the usual resizing of the cells globally when you open the excel file.
Wish this could just work when I use VbLf when exporting to a regular .xls Excel format file. Thanks again for the Tip!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top