Discussion Locked

send object - csv file

0 helpful
5 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

Can anyone give me a clue as to how to send a csv file direct from a query in Access, it will only allow a txt or xls.
Failing that - what vba would I use to send a file created on the hdd to an email recipient

either answer should be fully automated at the click of a button

Thanks

5 replies

by darla_668

save a txt file then take a look at it, is it a comma seperated list? when i export from an access querry and choose txt it gives me the option to choose delimited then choose the delimiter.

by timfox

If you were to perform the query through code, then you could ouput a comma-separated file yourself, similar to following:
----------
Dim dbs as database
dim rst as recordset

set dbs = currentdb

set rst = dbs.recordset("SELECT Record_ID, thisField, that field FROM thisTable WHERE thisField > 5")

if rst.recordcount < 1 then
msgbox "No records found"
set rst = nothing
set dbs = nothing
else
rst.movelast
rst.movefirst

while rst NOT EOF 'Check this line
' output each line to atext file here
wend
endif
set rst = nothing
set dbs = nothing
----------

You should find this website handy for sending email with MS Access:
http://www.granite.ab.ca/access/email.htm

Hope it helps.
TimFox

This discussion is closed to new replies.