By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,035 Members | 1,471 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,035 IT Pros & Developers. It's quick & easy.

Output data in a specific format

P: n/a
Hi there -

I really need a simple solution urgently, I have to export two fixed
length fields of 14 characters in lenth. as a sequential without
carriage returns.

ie.

original data

1234567890123412345678901234
120254201520 5688442002554
5225889945458655668423645888
358880200 6885ASDFWE

Result required

120254201520 5688442002554 120254201520 5688442002554
5225889945458655668423645888358880200 6885ASDFWE

etc..

is this possible?

Look forward to some assistance.

Regards

Steven
Nov 12 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Looking at your example data, your 2nd result is nothing at all like two 14
char fields exported sequentially. Further, did/do you want a new line after
the two fields, or just continues data?

However, assuming that your explanation is correct. You can use the
following code:

This code is writting as I type this email...it is untested air code.
So, te follwing should be *close* to a working example, but not perfect....

Sub Export

dim strOutFile as string
dim intOutFile as intger
dim rstRecs as dao.RecordSet
dim strSql as string
dim str1 as string(14)
dim str2 as string(14)

' get the data
strSql = "select field1,field2 from tblData order by field1"

' note how the above sql returns two fields. You can (and should) set
' the order. You can also add conditions to restrict the above data.

strOutfile = inputbox("What text file to output to?")

if strOutFile = "" then
exit sub
endif

intOutFile = freefile()

open strOutFile for output as #intOutFile

set rstRecs = currentdb.OpenrecordSet(strSql)

do while rstRecs.EOF = false
str1 = rstRecs!Field1
str2 = rstRecs!Field2
print #intOutFile,str1 & str2; ' continues data example
;print #intOutFile,str1 & str2 ' new line example
rstRecs.MoveNext
loop
rstRecs.Close
setRstRecs = nothing
close intOutFile
msgbox "exprot done.."

end MyExport

So, just past the above into a module and run it.
--
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada
No************@msn.com
http://www.attcanada.net/~kallal.msn
Nov 12 '05 #2

P: n/a
I'm having a hard time seeing the pattern you need to get from the original.
What is the first line of the "orignal data" in relation to the rest. I can
see you've concatenated the last two lines, but just repeated the 2 line
twice.

Mike Storr
www.veraccess.com

"Steven Sinfield" <me******@bigpond.com> wrote in message
news:29**************************@posting.google.c om...
Hi there -

I really need a simple solution urgently, I have to export two fixed
length fields of 14 characters in lenth. as a sequential without
carriage returns.

ie.

original data

1234567890123412345678901234
120254201520 5688442002554
5225889945458655668423645888
358880200 6885ASDFWE

Result required

120254201520 5688442002554 120254201520 5688442002554
5225889945458655668423645888358880200 6885ASDFWE

etc..

is this possible?

Look forward to some assistance.

Regards

Steven

Nov 12 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.