Ascii Line Separated File Format - Export
Ascii Line Separated File Format - Export
am 10.04.2008 12:28:09 von The Pipe
Hello
I have a table that I need to export to a .asc file format. I have had
several attempts at getting this to work but with no luck. Basically
the file would need to have every record displayed on a separate line
- If you like a CrLF delimited file. The unfortunate thing is that the
file is to be then imported into a third party piece of software and
as such I have no other alternative but to use this file format.
Does anyone have any bright ideas as to how I might achieve this?
Any pointers would be appreciated.
Re: Ascii Line Separated File Format - Export
am 10.04.2008 15:24:35 von Salad
The Pipe wrote:
> Hello
>
> I have a table that I need to export to a .asc file format. I have had
> several attempts at getting this to work but with no luck. Basically
> the file would need to have every record displayed on a separate line
> - If you like a CrLF delimited file. The unfortunate thing is that the
> file is to be then imported into a third party piece of software and
> as such I have no other alternative but to use this file format.
>
> Does anyone have any bright ideas as to how I might achieve this?
>
> Any pointers would be appreciated.
>
You mention you want a record displayed on a separate line then mention
a CrLF delimited file. Did you want a field per line?
123 Tom 1/1/2008
is 1 record per line. Or do you want
123
Tom
1/1/2008
as in a field per line?
If the second, you'll have to roll your own. The code below will get
you close.
Sub WriteFld()
Dim strFile As String
Dim rst As Recordset
Dim i As Integer
Set rst = CurrentDb.OpenRecordset("JunkTable", dbOpenSnapshot)
If rst.RecordCount > 0 Then
strFile = "C:\Test\Junk.Txt" 'output filename
Open strFile For Output As #1
rst.MoveFirst
Do While Not rst.EOF
'loop thru each field in the recordset and print value
For i = 0 To rst.Fields.Count - 1
Print #1, rst(i).Value
Next
rst.MoveNext
Loop
Close #1 'close output file
End If
rst.Close
Set rst = Nothing
End Sub
Traffic
http://www.youtube.com/watch?v=FG00Y1M6cDg
Re: Ascii Line Separated File Format - Export
am 10.04.2008 16:06:40 von Benny Andersen
On Thu, 10 Apr 2008 03:28:09 -0700 (PDT), The Pipe wrote:
> Hello
>
> I have a table that I need to export to a .asc file format. I have had
> several attempts at getting this to work but with no luck. Basically
> the file would need to have every record displayed on a separate line
> - If you like a CrLF delimited file. The unfortunate thing is that the
> file is to be then imported into a third party piece of software and
> as such I have no other alternative but to use this file format.
>
> Does anyone have any bright ideas as to how I might achieve this?
>
> Any pointers would be appreciated.
Try to experiment with the import wizard - making some table from a text
file of wanted format. Notice the import declaration facility - the
oppetunity to save a conversion specification.
That declaration can be used the other way around, by vba:
DoCmd.TransferText acExportDelim, specificationname,tablename,...
--
Benny Andersen
Re: Ascii Line Separated File Format - Export
am 10.04.2008 22:56:12 von The Pipe
On 10 Apr, 14:24, Salad wrote:
> The Pipe wrote:
> > Hello
>
> > I have a table that I need to export to a .asc file format. I have had
> > several attempts at getting this to work but with no luck. Basically
> > the file would need to have every record displayed on a separate line
> > - If you like a CrLF delimited file. The unfortunate thing is that the
> > file is to be then imported into a third party piece of software and
> > as such I have no other alternative but to use this file format.
>
> > Does anyone have any bright ideas as to how I might achieve this?
>
> > Any pointers would be appreciated.
>
> You mention you want a record displayed on a separate line then mention
> a CrLF delimited file. =A0Did you want a field per line?
> =A0 =A0 =A0 =A0 123 Tom 1/1/2008
> is 1 record per line. =A0Or do you want
> =A0 =A0 =A0 =A0 123
> =A0 =A0 =A0 =A0 Tom
> =A0 =A0 =A0 =A0 1/1/2008
> as in a field per line?
>
> If the second, you'll have to roll your own. =A0The code below will get
> you close.
>
> Sub WriteFld()
> =A0 =A0 =A0Dim strFile As String
> =A0 =A0 =A0Dim rst As Recordset
> =A0 =A0 =A0Dim i As Integer
>
> =A0 =A0 =A0Set rst =3D CurrentDb.OpenRecordset("JunkTable", dbOpenSnapshot=
)
> =A0 =A0 =A0If rst.RecordCount > 0 Then
> =A0 =A0 =A0 =A0 =A0strFile =3D "C:\Test\Junk.Txt" =A0'output filename
> =A0 =A0 =A0 =A0 =A0Open strFile For Output As #1
>
> =A0 =A0 =A0 =A0 =A0rst.MoveFirst
> =A0 =A0 =A0 =A0 =A0Do While Not rst.EOF
>
> =A0 =A0 =A0 =A0 =A0 =A0 'loop thru each field in the recordset and print v=
alue
> =A0 =A0 =A0 =A0 =A0 =A0 =A0For i =3D 0 To rst.Fields.Count - 1
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0Print #1, rst(i).Value
> =A0 =A0 =A0 =A0 =A0 =A0 =A0Next
> =A0 =A0 =A0 =A0 =A0 =A0 =A0rst.MoveNext
> =A0 =A0 =A0 =A0 =A0Loop
>
> =A0 =A0 =A0 =A0 =A0Close #1 =A0 =A0'close output file
> =A0 =A0 =A0End If
>
> =A0 =A0 =A0rst.Close
> =A0 =A0 =A0Set rst =3D Nothing
> End Sub
>
> Traffichttp://www.youtube.com/watch?v=3DFG00Y1M6cDg
Thanks Salad
I appreciate that my requirements were, at best, described in a
somewhat loose manner (Time is of the essence and all that). It was
the "second" one that I was after - one field per line - I shall give
your "get you close" code a trial as soon as I am able. I kinda get
the concept - whatever happens I am sure I will learn something new.
I will be sure to post the results.
Pipe
PS Top link (Traffic) - Reminds me of something.....
Re: Ascii Line Separated File Format - Export
am 10.04.2008 23:03:47 von Salad
The Pipe wrote:
> On 10 Apr, 14:24, Salad wrote:
>
>>The Pipe wrote:
>>
>>>Hello
>>
>>>I have a table that I need to export to a .asc file format. I have had
>>>several attempts at getting this to work but with no luck. Basically
>>>the file would need to have every record displayed on a separate line
>>>- If you like a CrLF delimited file. The unfortunate thing is that the
>>>file is to be then imported into a third party piece of software and
>>>as such I have no other alternative but to use this file format.
>>
>>>Does anyone have any bright ideas as to how I might achieve this?
>>
>>>Any pointers would be appreciated.
>>
>>You mention you want a record displayed on a separate line then mention
>>a CrLF delimited file. Did you want a field per line?
>> 123 Tom 1/1/2008
>>is 1 record per line. Or do you want
>> 123
>> Tom
>> 1/1/2008
>>as in a field per line?
>>
>>If the second, you'll have to roll your own. The code below will get
>>you close.
>>
>>Sub WriteFld()
>> Dim strFile As String
>> Dim rst As Recordset
>> Dim i As Integer
>>
>> Set rst = CurrentDb.OpenRecordset("JunkTable", dbOpenSnapshot)
>> If rst.RecordCount > 0 Then
>> strFile = "C:\Test\Junk.Txt" 'output filename
>> Open strFile For Output As #1
>>
>> rst.MoveFirst
>> Do While Not rst.EOF
>>
>> 'loop thru each field in the recordset and print value
>> For i = 0 To rst.Fields.Count - 1
>> Print #1, rst(i).Value
>> Next
>> rst.MoveNext
>> Loop
>>
>> Close #1 'close output file
>> End If
>>
>> rst.Close
>> Set rst = Nothing
>>End Sub
>>
>>Traffichttp://www.youtube.com/watch?v=FG00Y1M6cDg
>
>
> Thanks Salad
>
> I appreciate that my requirements were, at best, described in a
> somewhat loose manner (Time is of the essence and all that). It was
> the "second" one that I was after - one field per line - I shall give
> your "get you close" code a trial as soon as I am able. I kinda get
> the concept - whatever happens I am sure I will learn something new.
>
About all that needs to be changed is the table/query name...you could
pass that as an argument...and the output filename...which could also be
passed as an argument. Beyond that? I suppose you could add an error
routine.
> I will be sure to post the results.
That'd be nice.
>
> Pipe
>
> PS Top link (Traffic) - Reminds me of something.....
>
>
Re: Ascii Line Separated File Format - Export
am 11.04.2008 12:06:22 von The Pipe
On 10 Apr, 22:03, Salad wrote:
> The Pipe wrote:
> > On 10 Apr, 14:24, Salad wrote:
>
> >>The Pipe wrote:
>
> >>>Hello
>
> >>>I have a table that I need to export to a .asc file format. I have had
> >>>several attempts at getting this to work but with no luck. Basically
> >>>the file would need to have every record displayed on a separate line
> >>>- If you like a CrLF delimited file. The unfortunate thing is that the
> >>>file is to be then imported into a third party piece of software and
> >>>as such I have no other alternative but to use this file format.
>
> >>>Does anyone have any bright ideas as to how I might achieve this?
>
> >>>Any pointers would be appreciated.
>
> >>You mention you want a record displayed on a separate line then mention
> >>a CrLF delimited file. =A0Did you want a field per line?
> >> =A0 =A0 =A0 =A0123 Tom 1/1/2008
> >>is 1 record per line. =A0Or do you want
> >> =A0 =A0 =A0 =A0123
> >> =A0 =A0 =A0 =A0Tom
> >> =A0 =A0 =A0 =A01/1/2008
> >>as in a field per line?
>
> >>If the second, you'll have to roll your own. =A0The code below will get
> >>you close.
>
> >>Sub WriteFld()
> >> =A0 =A0 Dim strFile As String
> >> =A0 =A0 Dim rst As Recordset
> >> =A0 =A0 Dim i As Integer
>
> >> =A0 =A0 Set rst =3D CurrentDb.OpenRecordset("JunkTable", dbOpenSnapshot=
)
> >> =A0 =A0 If rst.RecordCount > 0 Then
> >> =A0 =A0 =A0 =A0 strFile =3D "C:\Test\Junk.Txt" =A0'output filename
> >> =A0 =A0 =A0 =A0 Open strFile For Output As #1
>
> >> =A0 =A0 =A0 =A0 rst.MoveFirst
> >> =A0 =A0 =A0 =A0 Do While Not rst.EOF
>
> >> =A0 =A0 =A0 =A0 =A0 =A0'loop thru each field in the recordset and print=
value
> >> =A0 =A0 =A0 =A0 =A0 =A0 For i =3D 0 To rst.Fields.Count - 1
> >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 Print #1, rst(i).Value
> >> =A0 =A0 =A0 =A0 =A0 =A0 Next
> >> =A0 =A0 =A0 =A0 =A0 =A0 rst.MoveNext
> >> =A0 =A0 =A0 =A0 Loop
>
> >> =A0 =A0 =A0 =A0 Close #1 =A0 =A0'close output file
> >> =A0 =A0 End If
>
> >> =A0 =A0 rst.Close
> >> =A0 =A0 Set rst =3D Nothing
> >>End Sub
>
> >>Traffichttp://www.youtube.com/watch?v=3DFG00Y1M6cDg
>
> > Thanks Salad
>
> > I appreciate that my requirements were, at best, described in a
> > somewhat loose manner (Time is of the essence and all that). It was
> > the "second" one that I was after - one field per line - I shall give
> > your "get you close" code a trial as soon as I am able. I kinda get
> > the concept - whatever happens I am sure I will learn something new.
>
> About all that needs to be changed is the table/query name...you could
> pass that as an argument...and the output filename...which could also be
> passed as an argument. =A0Beyond that? =A0I suppose you could add an error=
> routine.
>
> > I will be sure to post the results.
>
> That'd be nice.
>
>
>
>
>
> > Pipe
>
> > PS Top link (Traffic) - Reminds me of something.....- Hide quoted text -=
>
> - Show quoted text -- Hide quoted text -
>
> - Show quoted text -
I have given this a go but Access keeps calling runtime error 3001 -
Invalid Argument.
I have done a bit of investigation but have come up with nothing - any
ideas?
Re: Ascii Line Separated File Format - Export
am 11.04.2008 19:38:10 von Salad
The Pipe wrote:
> On 10 Apr, 22:03, Salad wrote:
>
>>The Pipe wrote:
>>
>>>On 10 Apr, 14:24, Salad wrote:
>>
>>>>The Pipe wrote:
>>
>>>>>Hello
>>
>>>>>I have a table that I need to export to a .asc file format. I have had
>>>>>several attempts at getting this to work but with no luck. Basically
>>>>>the file would need to have every record displayed on a separate line
>>>>>- If you like a CrLF delimited file. The unfortunate thing is that the
>>>>>file is to be then imported into a third party piece of software and
>>>>>as such I have no other alternative but to use this file format.
>>
>>>>>Does anyone have any bright ideas as to how I might achieve this?
>>
>>>>>Any pointers would be appreciated.
>>
>>>>You mention you want a record displayed on a separate line then mention
>>>>a CrLF delimited file. Did you want a field per line?
>>>> 123 Tom 1/1/2008
>>>>is 1 record per line. Or do you want
>>>> 123
>>>> Tom
>>>> 1/1/2008
>>>>as in a field per line?
>>
>>>>If the second, you'll have to roll your own. The code below will get
>>>>you close.
>>
>>>>Sub WriteFld()
>>>> Dim strFile As String
>>>> Dim rst As Recordset
>>>> Dim i As Integer
>>
>>>> Set rst = CurrentDb.OpenRecordset("JunkTable", dbOpenSnapshot)
>>>> If rst.RecordCount > 0 Then
>>>> strFile = "C:\Test\Junk.Txt" 'output filename
>>>> Open strFile For Output As #1
>>
>>>> rst.MoveFirst
>>>> Do While Not rst.EOF
>>
>>>> 'loop thru each field in the recordset and print value
>>>> For i = 0 To rst.Fields.Count - 1
>>>> Print #1, rst(i).Value
>>>> Next
>>>> rst.MoveNext
>>>> Loop
>>
>>>> Close #1 'close output file
>>>> End If
>>
>>>> rst.Close
>>>> Set rst = Nothing
>>>>End Sub
>>
>>>>Traffichttp://www.youtube.com/watch?v=FG00Y1M6cDg
>>
>>>Thanks Salad
>>
>>>I appreciate that my requirements were, at best, described in a
>>>somewhat loose manner (Time is of the essence and all that). It was
>>>the "second" one that I was after - one field per line - I shall give
>>>your "get you close" code a trial as soon as I am able. I kinda get
>>>the concept - whatever happens I am sure I will learn something new.
>>
>>About all that needs to be changed is the table/query name...you could
>>pass that as an argument...and the output filename...which could also be
>>passed as an argument. Beyond that? I suppose you could add an error
>>routine.
>>
>>
>>>I will be sure to post the results.
>>
>>That'd be nice.
>>
>>
>>
>>
>>
>>
>>>Pipe
>>
>>>PS Top link (Traffic) - Reminds me of something.....- Hide quoted text -
>>
>>- Show quoted text -- Hide quoted text -
>>
>>- Show quoted text -
>
>
> I have given this a go but Access keeps calling runtime error 3001 -
> Invalid Argument.
>
> I have done a bit of investigation but have come up with nothing - any
> ideas?
No, I don't.
The program should stop on the line it fails on. It it doesn't, comment
on the OnError routine temporarily.
I changed the line
Set rst = CurrentDb.OpenRecordset("JunkTable", dbOpenSnapshot)
to
Set rst = CurrentDb.OpenRecordset("Table1", dbOpenSnapshot)
which happens to be a table I have.
I then changed
strFile = "C:\Test\Junk.Txt" 'output filename
to
strFile = "C:\Table1.Txt" 'output filename
and then ran the code. It ran as expected and it created Table1.Txt as
the output file in the format you desire.
I suppose you could make it generic and have the sub be
Sub WriteFld(strFile As String, strTable As String)
and change the rst line to
Set rst = CurrentDb.OpenRecordset(strTable, dbOpenSnapshot)
and remove the lines
Dim strFile As String
strFile = "C:\Test\Junk.Txt" 'output filename
Then from a program or immediate window w/o the Dim statements you could
call the routine like this.
Dim strFile As String
Dim strTable As String
strFile = "C:\Junk.Txt"
strTable = "Customers"
WriteFld strFile, strTable
Bakerman
http://www.youtube.com/watch?v=ymdssZOAx3Q
Re: Ascii Line Separated File Format - Export
am 15.04.2008 20:22:12 von The Pipe
On 11 Apr, 18:38, Salad wrote:
> The Pipe wrote:
> > On 10 Apr, 22:03, Salad wrote:
>
> >>The Pipe wrote:
>
> >>>On 10 Apr, 14:24, Salad wrote:
>
> >>>>The Pipe wrote:
>
> >>>>>Hello
>
> >>>>>I have a table that I need to export to a .asc file format. I have ha=
d
> >>>>>several attempts at getting this to work but with no luck. Basically
> >>>>>the file would need to have every record displayed on a separate line=
> >>>>>- If you like a CrLF delimited file. The unfortunate thing is that th=
e
> >>>>>file is to be then imported into a third party piece of software and
> >>>>>as such I have no other alternative but to use this file format.
>
> >>>>>Does anyone have any bright ideas as to how I might achieve this?
>
> >>>>>Any pointers would be appreciated.
>
> >>>>You mention you want a record displayed on a separate line then mentio=
n
> >>>>a CrLF delimited file. =A0Did you want a field per line?
> >>>> =A0 =A0 =A0 123 Tom 1/1/2008
> >>>>is 1 record per line. =A0Or do you want
> >>>> =A0 =A0 =A0 123
> >>>> =A0 =A0 =A0 Tom
> >>>> =A0 =A0 =A0 1/1/2008
> >>>>as in a field per line?
>
> >>>>If the second, you'll have to roll your own. =A0The code below will ge=
t
> >>>>you close.
>
> >>>>Sub WriteFld()
> >>>> =A0 =A0Dim strFile As String
> >>>> =A0 =A0Dim rst As Recordset
> >>>> =A0 =A0Dim i As Integer
>
> >>>> =A0 =A0Set rst =3D CurrentDb.OpenRecordset("JunkTable", dbOpenSnapsho=
t)
> >>>> =A0 =A0If rst.RecordCount > 0 Then
> >>>> =A0 =A0 =A0 =A0strFile =3D "C:\Test\Junk.Txt" =A0'output filename
> >>>> =A0 =A0 =A0 =A0Open strFile For Output As #1
>
> >>>> =A0 =A0 =A0 =A0rst.MoveFirst
> >>>> =A0 =A0 =A0 =A0Do While Not rst.EOF
>
> >>>> =A0 =A0 =A0 =A0 =A0 'loop thru each field in the recordset and print =
value
> >>>> =A0 =A0 =A0 =A0 =A0 =A0For i =3D 0 To rst.Fields.Count - 1
> >>>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0Print #1, rst(i).Value
> >>>> =A0 =A0 =A0 =A0 =A0 =A0Next
> >>>> =A0 =A0 =A0 =A0 =A0 =A0rst.MoveNext
> >>>> =A0 =A0 =A0 =A0Loop
>
> >>>> =A0 =A0 =A0 =A0Close #1 =A0 =A0'close output file
> >>>> =A0 =A0End If
>
> >>>> =A0 =A0rst.Close
> >>>> =A0 =A0Set rst =3D Nothing
> >>>>End Sub
>
> >>>>Traffichttp://www.youtube.com/watch?v=3DFG00Y1M6cDg
>
> >>>Thanks Salad
>
> >>>I appreciate that my requirements were, at best, described in a
> >>>somewhat loose manner (Time is of the essence and all that). It was
> >>>the "second" one that I was after - one field per line - I shall give
> >>>your "get you close" code a trial as soon as I am able. I kinda get
> >>>the concept - whatever happens I am sure I will learn something new.
>
> >>About all that needs to be changed is the table/query name...you could
> >>pass that as an argument...and the output filename...which could also be=
> >>passed as an argument. =A0Beyond that? =A0I suppose you could add an err=
or
> >>routine.
>
> >>>I will be sure to post the results.
>
> >>That'd be nice.
>
> >>>Pipe
>
> >>>PS Top link (Traffic) - Reminds me of something.....- Hide quoted text =
-
>
> >>- Show quoted text -- Hide quoted text -
>
> >>- Show quoted text -
>
> > I have given this a go but Access keeps calling runtime error 3001 -
> > Invalid Argument.
>
> > I have done a bit of investigation but have come up with nothing - any
> > ideas?
>
> No, I don't.
>
> The program should stop on the line it fails on. =A0It it doesn't, comment=
> on the OnError routine temporarily.
>
> I changed the line
> =A0 =A0 =A0 =A0 Set rst =3D CurrentDb.OpenRecordset("JunkTable", dbOpenSna=
pshot)
> to
> =A0 =A0 =A0 =A0 Set rst =3D CurrentDb.OpenRecordset("Table1", dbOpenSnapsh=
ot)
> which happens to be a table I have.
>
> I then changed
> =A0 =A0 =A0 =A0 strFile =3D "C:\Test\Junk.Txt" =A0'output filename
> to
> =A0 =A0 =A0 =A0 strFile =3D "C:\Table1.Txt" =A0'output filename
> and then ran the code. =A0It ran as expected and it created Table1.Txt as
> the output file in the format you desire.
>
> I suppose you could make it generic and have the sub be
> =A0 =A0 =A0 =A0 Sub WriteFld(strFile As String, strTable As String)
> and change the rst line to
> =A0 =A0 =A0 =A0 Set rst =3D CurrentDb.OpenRecordset(strTable, dbOpenSnapsh=
ot)
> and remove the lines
> =A0 =A0 =A0 =A0 =A0Dim strFile As String
> =A0 =A0 =A0 =A0 strFile =3D "C:\Test\Junk.Txt" =A0'output filename
>
> Then from a program or immediate window w/o the Dim statements you could
> call the routine like this.
> =A0 =A0 =A0 =A0 Dim strFile As String
> =A0 =A0 =A0 =A0 Dim strTable As String
>
> =A0 =A0 =A0 =A0 strFile =3D "C:\Junk.Txt"
> =A0 =A0 =A0 =A0 strTable =3D "Customers"
> =A0 =A0 =A0 =A0 WriteFld strFile, strTable
>
> Bakermanhttp://www.youtube.com/watch?v=3DymdssZOAx3Q- Hide quoted text -
>
> - Show quoted text -
Finally got to try this at home and has worked a treat!
I put in a little extra that catches any nulls and ouputs them as zero
length strings (The output file contained the text "Null" wherever
there was one from the source).
Can't thank you enough for your help with this salad.
Re: Ascii Line Separated File Format - Export
am 15.04.2008 21:14:34 von Salad
The Pipe wrote:
> On 11 Apr, 18:38, Salad wrote:
>
>>The Pipe wrote:
>>
>>>On 10 Apr, 22:03, Salad wrote:
>>
>>>>The Pipe wrote:
>>
>>>>>On 10 Apr, 14:24, Salad wrote:
>>
>>>>>>The Pipe wrote:
>>
>>>>>>>Hello
>>
>>>>>>>I have a table that I need to export to a .asc file format. I have had
>>>>>>>several attempts at getting this to work but with no luck. Basically
>>>>>>>the file would need to have every record displayed on a separate line
>>>>>>>- If you like a CrLF delimited file. The unfortunate thing is that the
>>>>>>>file is to be then imported into a third party piece of software and
>>>>>>>as such I have no other alternative but to use this file format.
>>
>>>>>>>Does anyone have any bright ideas as to how I might achieve this?
>>
>>>>>>>Any pointers would be appreciated.
>>
>>>>>>You mention you want a record displayed on a separate line then mention
>>>>>>a CrLF delimited file. Did you want a field per line?
>>>>>> 123 Tom 1/1/2008
>>>>>>is 1 record per line. Or do you want
>>>>>> 123
>>>>>> Tom
>>>>>> 1/1/2008
>>>>>>as in a field per line?
>>
>>>>>>If the second, you'll have to roll your own. The code below will get
>>>>>>you close.
>>
>>>>>>Sub WriteFld()
>>>>>> Dim strFile As String
>>>>>> Dim rst As Recordset
>>>>>> Dim i As Integer
>>
>>>>>> Set rst = CurrentDb.OpenRecordset("JunkTable", dbOpenSnapshot)
>>>>>> If rst.RecordCount > 0 Then
>>>>>> strFile = "C:\Test\Junk.Txt" 'output filename
>>>>>> Open strFile For Output As #1
>>
>>>>>> rst.MoveFirst
>>>>>> Do While Not rst.EOF
>>
>>>>>> 'loop thru each field in the recordset and print value
>>>>>> For i = 0 To rst.Fields.Count - 1
>>>>>> Print #1, rst(i).Value
>>>>>> Next
>>>>>> rst.MoveNext
>>>>>> Loop
>>
>>>>>> Close #1 'close output file
>>>>>> End If
>>
>>>>>> rst.Close
>>>>>> Set rst = Nothing
>>>>>>End Sub
>>
>>>>>>Traffichttp://www.youtube.com/watch?v=FG00Y1M6cDg
>>
>>>>>Thanks Salad
>>
>>>>>I appreciate that my requirements were, at best, described in a
>>>>>somewhat loose manner (Time is of the essence and all that). It was
>>>>>the "second" one that I was after - one field per line - I shall give
>>>>>your "get you close" code a trial as soon as I am able. I kinda get
>>>>>the concept - whatever happens I am sure I will learn something new.
>>
>>>>About all that needs to be changed is the table/query name...you could
>>>>pass that as an argument...and the output filename...which could also be
>>>>passed as an argument. Beyond that? I suppose you could add an error
>>>>routine.
>>
>>>>>I will be sure to post the results.
>>
>>>>That'd be nice.
>>
>>>>>Pipe
>>
>>>>>PS Top link (Traffic) - Reminds me of something.....- Hide quoted text -
>>
>>>>- Show quoted text -- Hide quoted text -
>>
>>>>- Show quoted text -
>>
>>>I have given this a go but Access keeps calling runtime error 3001 -
>>>Invalid Argument.
>>
>>>I have done a bit of investigation but have come up with nothing - any
>>>ideas?
>>
>>No, I don't.
>>
>>The program should stop on the line it fails on. It it doesn't, comment
>>on the OnError routine temporarily.
>>
>>I changed the line
>> Set rst = CurrentDb.OpenRecordset("JunkTable", dbOpenSnapshot)
>>to
>> Set rst = CurrentDb.OpenRecordset("Table1", dbOpenSnapshot)
>>which happens to be a table I have.
>>
>>I then changed
>> strFile = "C:\Test\Junk.Txt" 'output filename
>>to
>> strFile = "C:\Table1.Txt" 'output filename
>>and then ran the code. It ran as expected and it created Table1.Txt as
>>the output file in the format you desire.
>>
>>I suppose you could make it generic and have the sub be
>> Sub WriteFld(strFile As String, strTable As String)
>>and change the rst line to
>> Set rst = CurrentDb.OpenRecordset(strTable, dbOpenSnapshot)
>>and remove the lines
>> Dim strFile As String
>> strFile = "C:\Test\Junk.Txt" 'output filename
>>
>>Then from a program or immediate window w/o the Dim statements you could
>>call the routine like this.
>> Dim strFile As String
>> Dim strTable As String
>>
>> strFile = "C:\Junk.Txt"
>> strTable = "Customers"
>> WriteFld strFile, strTable
>>
>>Bakermanhttp://www.youtube.com/watch?v=ymdssZOAx3Q- Hide quoted text -
>>
>>- Show quoted text -
>
>
> Finally got to try this at home and has worked a treat!
>
> I put in a little extra that catches any nulls and ouputs them as zero
> length strings (The output file contained the text "Null" wherever
> there was one from the source).
>
> Can't thank you enough for your help with this salad.
>
You're welcome. Compliments are our pay and are appreciated.
This group is par excellent in assisting people.
CDMA Made Me Do It.
http://www.youtube.com/watch?v=HzeZhCt5PVA