473,378 Members | 1,391 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Preparing data for exporting

A friend of mine has to export some data from his current access
database into a CSV file to be imported into an accounting package.

There are a few things that need to be done most of which I am quie
capable of doing. For expample writing the query to grab all the
relevant data is fine.
Building the macro to export the data via transfertext is also fine.

The problem I have lies in his product description field. In his
database it is a simple text field set to 255 characters.
The program which it is going to go to can only accept 30 characters
per line for the description field.
What I have to do is put a CrLf after every 30 characters in the
product description field, for every record before it is exported.

I am quessing here that the solution will be a VBA one. I understand
the basics of VBA however you might need to take it slowly with me.

I really hope someone can help me with this problem.
Nov 12 '05 #1
4 1970
Hmmm...

I assume that the target table has, say 4 or 5 fields (Desc1,
Desc2,Desc3,Desc4,Desc5) to store the descrition each is 30 chars.

You could avoid VBA using a query, but you should get your hands dirty.
However, here is a possible non vba way.....
You could create a query that uses the MID( ) function to strip out each
block of 30 chars.

SELECT
MID(Description,1,30) AS Desc1,
MID(Description,31,30) AS Desc2,
MID(Description,62,30) AS Desc3,
MID(Description,93,30) AS Desc4,
MID(Description,124,30) AS Desc5,
FROM
tblProducts

"David" <oz****@bigpond.net.au> wrote in message
news:a4**************************@posting.google.c om...
A friend of mine has to export some data from his current access
database into a CSV file to be imported into an accounting package.

There are a few things that need to be done most of which I am quie
capable of doing. For expample writing the query to grab all the
relevant data is fine.
Building the macro to export the data via transfertext is also fine.

The problem I have lies in his product description field. In his
database it is a simple text field set to 255 characters.
The program which it is going to go to can only accept 30 characters
per line for the description field.
What I have to do is put a CrLf after every 30 characters in the
product description field, for every record before it is exported.

I am quessing here that the solution will be a VBA one. I understand
the basics of VBA however you might need to take it slowly with me.

I really hope someone can help me with this problem.

Nov 12 '05 #2
Thanks for the suggestion Nigel unfortunatly the target
table/application will have just a single field.

The target table(not in access) can handle multiline text fields
provided each line is marked by a CrLF.

So what I have is in my mates DB a whole heap of products some are
under 30 chars others are well over 180. I have to insert a CrLF into
each product description field at the 30,60, 90 etc marks.
WHen the target application imports this it will place the text after
the CrLf on the next line. Without the CrLf it will truncate the field
which is not what he wants.
"Nigel tombs" <ic*****@tiscali.co.uk> wrote in message news:<40********@mk-nntp-2.news.uk.tiscali.com>...
Hmmm...

I assume that the target table has, say 4 or 5 fields (Desc1,
Desc2,Desc3,Desc4,Desc5) to store the descrition each is 30 chars.

You could avoid VBA using a query, but you should get your hands dirty.
However, here is a possible non vba way.....
You could create a query that uses the MID( ) function to strip out each
block of 30 chars.

SELECT
MID(Description,1,30) AS Desc1,
MID(Description,31,30) AS Desc2,
MID(Description,62,30) AS Desc3,
MID(Description,93,30) AS Desc4,
MID(Description,124,30) AS Desc5,
FROM
tblProducts

Nov 12 '05 #3
oz****@bigpond.net.au (David) wrote in message news:<a4**************************@posting.google. com>...
Thanks for the suggestion Nigel unfortunatly the target
table/application will have just a single field.

The target table(not in access) can handle multiline text fields
provided each line is marked by a CrLF.

So what I have is in my mates DB a whole heap of products some are
under 30 chars others are well over 180. I have to insert a CrLF into
each product description field at the 30,60, 90 etc marks.
WHen the target application imports this it will place the text after
the CrLf on the next line. Without the CrLf it will truncate the field
which is not what he wants.


Only way I can think of doing it if you can't use a query is to use VB
loop through the table one record at a time and do something like what
Nigel suggested.

Something like...
-create a holder variable for your new string
Do until you've read all chars
-read the nth 30 characters off the field's contents
-write that to your variable and append a CrLf
Loop

when you get to the end of the string, write it back to the field it
came from.
Nov 12 '05 #4
rkc
David wrote:
Thanks for the suggestion Nigel unfortunatly the target
table/application will have just a single field.

The target table(not in access) can handle multiline text fields
provided each line is marked by a CrLF.

So what I have is in my mates DB a whole heap of products some are
under 30 chars others are well over 180. I have to insert a CrLF into
each product description field at the 30,60, 90 etc marks.
WHen the target application imports this it will place the text after
the CrLf on the next line. Without the CrLf it will truncate the field
which is not what he wants.


You could use a vba function in an update query.
Something like

UPDATE TableName
SET FieldWithBreaks = AddBreak(FieldWithoutBreaks,30);

<AddBreak Function>
Function AddBreak(s As String, break As Integer) As String
Dim i As Integer
Dim lastSpace As Integer
Dim c As String
Dim workStr As String
Dim result As String

workStr = s

Do While Len(workStr) > break
lastSpace = 0
For i = 1 To Len(workStr)
c = Mid$(workStr, i, 1)
If c = " " Then lastSpace = i
If i = break Then
result = result & Left$(workStr, lastSpace - 1) & vbCrLf
workStr = Mid$(workStr, lastSpace + 1)
Exit For
End If
Next
Loop

AddBreak = result & workStr

End Function
</AddBReak Function>

Nov 12 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Angel Cat | last post by:
I'm exporting a large file from a large Production database (SQL). Users are currently updating and inserting new records. Does the export take a snapshot of the data when it starts ? or will...
3
by: sridevi | last post by:
Hello How to export data from ms-access database to excel worksheet using ASP. mainly i need to export data to multiple worksheets. it is very urgent to us. i have a sample code which works...
1
by: Andrew Arace | last post by:
I scoured the groups for some hands on code to perform the menial task of exporting table data from an Access 2000 database to Oracle database (in this case, it was oracle 8i but i'm assuming this...
2
by: Andy Davis | last post by:
Has anybody tried and had any success exporting data directly from ACT! 2000 to an Access database? I need to transfer data from ACT! to Access, but the data is all imported as text, including date...
2
by: pmud | last post by:
Hi, I am exporting data from an EDITABLE DATA GRID EXCEL. But the 1st column in data grid is Edit Column. I want to display all columns in Excel except for the Edit column. The following...
2
by: bienwell | last post by:
Hi, I have a question about exporting data from datagrid control into Excel file in ASP.NET. On my Web page, I have a linkbutton "Export data". This link will call a Sub Function to perform...
2
by: Mux | last post by:
I am facing the following problem while exporting data to Word. The current implementation is as described below: I have a JSP file which has a link that enables you to export the data to Word....
6
by: sara | last post by:
I have what I think is a little strange...I have to get data from our payroll system into a specific format (fixed record length) as a .txt or .prn file only to upload to our 401k custodian. I...
2
by: billelev | last post by:
Hi there, My question does not concern the exporting of data to CSV so much as the format of the exported data. The data to be exported consists of a time series of prices for a number of assets....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.