Hello,
I wrote a query that I have a macro setup to run and export the results to a text file. When I run the query, the results are correct when shown in the results (select query) view in Access, but when I extract it to a text file, it doesnt extract it as needed. The problem is related to the field being numeric I think.
The query I am running is:
______________________
SELECT "T9" AS RECTYPE,
"92" AS AGENCYD,
"01" AS LOC,
" " AS FILLA1,
"TR0" AS BATCH1,
[Extract Date].DAY AS BATCH2,
" " AS FILLB1,
SELECT FORMAT(count(*),"0000000") FROM [Lead Data] WHERE [Extract Date].DAY = [Lead Data].CALL_DAY) AS REC_CNT,
" " AS FILLC1,
SELECT FORMAT(sum(right([Lead Data.Phone],4)),"000000000000000") FROM [Lead Data] WHERE [Extract Date].DAY = [Lead Data].CALL_DAY) AS HASH,
" " AS FILLD864
FROM [Extract Date];
______________________
The problem is related to the two embedded select statements within the query.
The first is counting the number of records in the table and returning a number (example: 10) and then adding zero padding to the left (Example: 000010).
The second is counting the last four bytes of a phone number for all the records in the table, and then adding zero padding to the left (Example: 000000000002315).
When looking at this in Access, I see
REC_CNT = 000010
Hash = 000000000002315
... these are both correct.
The problem is when I extract them to a text file.
The field '000010' is extracting into the file as '10 '
The field '000000000002315' is extrating into the file as '23.15 '
WOuld anyone have a recommendation for how I can extract it with the zero padding included and the decimal points removed.
Thanks!
I wrote a query that I have a macro setup to run and export the results to a text file. When I run the query, the results are correct when shown in the results (select query) view in Access, but when I extract it to a text file, it doesnt extract it as needed. The problem is related to the field being numeric I think.
The query I am running is:
______________________
SELECT "T9" AS RECTYPE,
"92" AS AGENCYD,
"01" AS LOC,
" " AS FILLA1,
"TR0" AS BATCH1,
[Extract Date].DAY AS BATCH2,
" " AS FILLB1,
SELECT FORMAT(count(*),"0000000") FROM [Lead Data] WHERE [Extract Date].DAY = [Lead Data].CALL_DAY) AS REC_CNT,
" " AS FILLC1,
SELECT FORMAT(sum(right([Lead Data.Phone],4)),"000000000000000") FROM [Lead Data] WHERE [Extract Date].DAY = [Lead Data].CALL_DAY) AS HASH,
" " AS FILLD864
FROM [Extract Date];
______________________
The problem is related to the two embedded select statements within the query.
The first is counting the number of records in the table and returning a number (example: 10) and then adding zero padding to the left (Example: 000010).
The second is counting the last four bytes of a phone number for all the records in the table, and then adding zero padding to the left (Example: 000000000002315).
When looking at this in Access, I see
REC_CNT = 000010
Hash = 000000000002315
... these are both correct.
The problem is when I extract them to a text file.
The field '000010' is extracting into the file as '10 '
The field '000000000002315' is extrating into the file as '23.15 '
WOuld anyone have a recommendation for how I can extract it with the zero padding included and the decimal points removed.
Thanks!