Here is what I did.
SELECT
tblCompanyInfo.BankCode, tblCompanyInfo.BAcctNo,
tblEmployeeInfo.ACCTNO, Format(([NETPAY] *
100), "000000000000000") AS AMOUNT,
Format([PAYDATE], "yyyymmdd") AS PD, 2 AS SortCode
FROM
tblCompanyInfo, tblPayrollTransactions
INNER JOIN
tblEmployeeInfo
ON
tblPayrollTransactions.EMPID = tblEmployeeInfo.EMPID
UNION SELECT
"001" AS SSortCode, 1171051776 AS SSSortCode,
tblPayrollTransactions.PAYCODE,
Format(Sum([NETPAY] * 100), "000000000000000") AS
SumOfNETPAY,
Format([PAYDATE], "yyyymmdd") AS PD, 1 AS SortCode
FROM
tblPayrollTransactions
GROUP BY
tblPayrollTransactions.PAYCODE,
tblPayrollTransactions.PAYDATE
ORDER BY SortCode;
And in the command button, on the OnClick event, I used
this command:
DoCmd.TransferText
acExportDelim, "", "unionqryAdvise", "D:\Advise.txt",
False, ""
and the output was this:
"001","5555555555","0000000001","000000015272892","20030806
",1
"001","1171051776","1171096899","000000000079845","20030806
",2
"001","1171051776","1171096991","000000000211743","20030806
",2
I need an output that excludes the commas and quotation
marks and without the value for the SortCode just like
this,
0015555555555000000000100000001527289220030806
0011171051776117109689900000000007984520030806
0011171051776117109699100000000021174320030806
At this point I'm already lost. I need your help badly.
Thanks for the reply and the suggestion. I could sure use
some of your suggestions right now.
Thanks very much.
-----Original Message-----
Hi Arvin,
There are basically two ways to go. One is to use a union query with a
dummy field to ensure that the group code goes in the first line; the
other is to use VBA and recordset operations to write the output file
line by line.
For the union query, start with a query that pulls the output you need
from tblTrans, adding a dummy "SortCode" field:
SELECT
CODE, PAYCODE, AMOUNT, 2 AS SortCode
FROM tblTrans
WHERE blah;
When that's working right, build a second query that pulls the values
you need for the first line of the file, again adding a dummy field for
sorting. At a guess it will be a totals query joining tblTrans and
tblGrp, grouped on CODE and on the dummy field
1 AS SortCode
Then combine the SQL of these two queries with the UNION operator and
add an ORDER BY clause:
SELECT
CODE, PAYCODE, AMOUNT, 2 AS SortCode
FROM tblTrans
UNION
SELECT
blah blah
FROM blah
GROUP BY blah
ORDER BY SortCode, Code, PayCode;
Finally, export the three fields you're interested in to a fixed-width
textfile.
I have this table named tblTrans and I need to
transfer this into MS-DOS Text format.
I have used the DoCmd.TransferText command.
My table looks like this:
CODE | PAYCODE | AMOUNT |
001 001 235
001 001 111
001 001 213
001 001 212
My output should look like this
001111771
001001235
001001111
001001213
001001212
Where the first line should contain 111 as the group code
(found in another table named tblGrp) and 771 is
the total amount.
What do you think should I do with this?
I need your help. I would apprecaite whatever assistance
you would be able to extend. Thanks.
John Nurick [Microsoft Access MVP]
Please respond in the newgroup and not by email.
.