Hum, that certainly is a differ format. (6 records on the same line???).
Anyway, since this format is so un-standard...then you will have to roll
your own....
You can actually write code to output text directly to a file.
So, I would roll my own. You need to checkout the open, and print commands
in the help.
Here is basic code shell that will output query to a txt file. Of course, I
will leave it up to you to polish the code, put it behind a button, and
popup up the file browse dialog etc. All that nice user interface stuff is
up to you..but the basic code shell to export looks like:
Dim strFile As String
Dim intF As Integer
Dim strLine As String
Dim rst As dao.Recordset
Dim strSql As String
Dim i As Integer
' set name of output file. (you
' could prompt user for the file name
' here)
strFile = "c:\my data\MyData.txt"
intF = FreeFile()
Open strFile For Output As #intF
strSql = "select * from tblCustomer where City = 'Edmonton'" & _
" and lastName Is not null order by LastName"
' note how I set conditions, and most importantly set the order
' of the data in the above. You can (and should) consider using
' a query for the above,a nd go
' strSql = "myqueryName"
Set rst = CurrentDb.OpenRecordset(strSql)
Do While rst.EOF = False
For i = 1 To 6
strLine = Format(Nz(rst!LastName), "!@@@@@@@@@@") & _
Format(Nz(rst!FirstName), "!@@@@@@@@@@")
Print #intF, strLine;
rst.MoveNext
If rst.EOF = True Then
Exit For
End If
Next i
' done outputing 6 lines...send a new line char...
Print #intF, ""
Loop
Close intF
rst.Close
Set rst = Nothing
The above would output the FirstName, LastName (finxed lengh each of 10
chars) 6 to a line...
Also, if the field in the reocrd set is longer, then the format string..you
have to first truncate.
So, a better sytnax might be:
strBuf = left(nz(rst!LastName),10)
(the above is now a MAX of 10 chars..and will truncate the lenght of the
last name..yo then go
print #intF,format(strBuf,"!@@@@@@@@@@");
So, you don't have to put all the data into strLine in one swipe..but can
out each field one at a time...
Note the format commands, the @@@@ pad with spaces. If you elimaonte the !,
then padding is righ just
so:
? "<" & format("abc","!@@@@@@@@@@") & ">" gives
<abc >
and
? "<" & format("abc","@@@@@@@@@@") & ">" gives
< abc>
--
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada
(E-Mail Removed)
http://www.attcanada.net/~kallal.msn