473,385 Members | 1,848 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Export Access Data to Excel, Zip, Send Email

4
Hello,
I'm a non_VBA coder who has been asked to update the following Function:

**************************

Function EMAILER_REV_BY_ACCTCODE_MACRO()

On Error GoTo RA_EMAILER_Err

DoCmd.SetWarnings False
DoCmd.SelectObject acForm, "SalesAssoc", False
DoCmd.SendObject acQuery, "Rev by AcctCode", "MicrosoftExcel(*.xls)", Forms![SalesAssoc]![e-mail], "", "", "Spreadsheet of Core Revenue for Current Month by Account", "Attached please find an Excel spreadsheet of the Core revenue for your Accounts. ", False, ""
DoCmd.RunCommand acCmdRefreshPage
DoCmd.RunCommand acCmdRecordsGoToNext

RA_EMAILER_Exit:
Exit Function

RA_EMAILER_Err:
MsgBox Error$

End Function
********************************
The function works fine, but the size of the unzipped Excel file is too large to send via email (mailbox size restriction). The user has WinZip installed on their computer. My thought is that the code needs to be modified so that the query is called and the results sent to an Excel file, then zip the file, then email the zipped file. I've tested zipping the Excel file, and the resulting size is well within the mailbox size limit.

How can I modify the above code to populate the Excel file with the query results, zip the file, then send it via email? I've searched online for some ideas, but have not really found anything.

The code is contained within an MS Access 2000 Module. The O/S is Windows XP SP2.

Thank you for your help!

cdun2
Mar 26 '07 #1
5 5738
Rabbit
12,516 Expert Mod 8TB
Hello,
I'm a non_VBA coder who has been asked to update the following Function:

**************************

Function EMAILER_REV_BY_ACCTCODE_MACRO()

On Error GoTo RA_EMAILER_Err

DoCmd.SetWarnings False
DoCmd.SelectObject acForm, "SalesAssoc", False
DoCmd.SendObject acQuery, "Rev by AcctCode", "MicrosoftExcel(*.xls)", Forms![SalesAssoc]![e-mail], "", "", "Spreadsheet of Core Revenue for Current Month by Account", "Attached please find an Excel spreadsheet of the Core revenue for your Accounts. ", False, ""
DoCmd.RunCommand acCmdRefreshPage
DoCmd.RunCommand acCmdRecordsGoToNext

RA_EMAILER_Exit:
Exit Function

RA_EMAILER_Err:
MsgBox Error$

End Function
********************************
The function works fine, but the size of the unzipped Excel file is too large to send via email (mailbox size restriction). The user has WinZip installed on their computer. My thought is that the code needs to be modified so that the query is called and the results sent to an Excel file, then zip the file, then email the zipped file. I've tested zipping the Excel file, and the resulting size is well within the mailbox size limit.

How can I modify the above code to populate the Excel file with the query results, zip the file, then send it via email? I've searched online for some ideas, but have not really found anything.

The code is contained within an MS Access 2000 Module. The O/S is Windows XP SP2.

Thank you for your help!

cdun2
You'll have to figure out the exact command line syntax but you can use Call Shell("text") to run a command line program.

As for the e-mail, I've never e-mailed anything with Access so someone else will have to help you there.
Mar 26 '07 #2
cdun2
4
I got this to work:

DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "Rev by AcctCode", "C:\Learning\ZipExcelFile\Results.xls"

The problem is, "Rev by AcctCode" is an MS Access Query that takes the following parameter value; Forms![SalesAssoc]![e-mail].

I need the parameter to get the correct results into the spreadsheet. How can I do this?

I have the code to send the email attachment (SendObject), and I have the code to zip the file. All I need is to figure out is how to use a parameter query with 'TransferSpreadsheet' .

Thanks again!
Mar 26 '07 #3
MMcCarthy
14,534 Expert Mod 8TB
I got this to work:

DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "Rev by AcctCode", "C:\Learning\ZipExcelFile\Results.xls"

The problem is, "Rev by AcctCode" is an MS Access Query that takes the following parameter value; Forms![SalesAssoc]![e-mail].

I need the parameter to get the correct results into the spreadsheet. How can I do this?

I have the code to send the email attachment (SendObject), and I have the code to zip the file. All I need is to figure out is how to use a parameter query with 'TransferSpreadsheet' .

Thanks again!
Make sure the SalesAssoc form is open to the appropriate record and the TransferSpreadsheet should work fine.

Mary
Mar 26 '07 #4
cdun2
4
But there are other controls on the form. How can there be any association of the value in Forms![SalesAssoc]![e-mail] to the 'Rev by AcctCode' parameter query? I wouldn't think that when using TransferSpreadsheet that when the query is a parameter query, that I can 'assume' the form field that holds the parameter.
Mar 26 '07 #5
MMcCarthy
14,534 Expert Mod 8TB
But there are other controls on the form. How can there be any association of the value in Forms![SalesAssoc]![e-mail] to the 'Rev by AcctCode' parameter query? I wouldn't think that when using TransferSpreadsheet that when the query is a parameter query, that I can 'assume' the form field that holds the parameter.
It is the query that assumes the value. Try it and see.
Mar 26 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Raymond | last post by:
Need to export an existing M$ Access 97 database to Postgres. Tuples must be filtered as I am using sequences and other constraints. Help from anyone that has experience with this or know of...
1
by: Steven Stewart | last post by:
I have a user who has been using Excel for a while to keep statistics and print reports. She finds using it cumbersome because of long formulas and a lot of copying and pasting. I have designed...
2
by: PerryC | last post by:
Is there a way to export an MS Access Report to Word/Excel that looks EXACTLY like it appears in Access? When I export to Excel, only certain data appears, titles, headings... all missing. The...
5
by: Jonny | last post by:
Hello, I have created a button on my form which when pressed does the following : 1) Run a pre-defined Macro, which is picking up a query and running my data to excel. However, I need the...
13
by: Hemant Sipahimalani | last post by:
The following piece of code is being used to export HTML to excel. HttpContext.Current.Response.ContentType = "application/vnd.ms-excel"...
1
by: smaczylo | last post by:
Hello, I've recently been asked to work with Microsoft Access, and while I feel quite comfortable with Excel, I'm at a complete loss with databases. If someone could help me with this issue I'm...
1
by: CoolFactor | last post by:
MY CODE IS NEAR THE BOTTOM I want to export this Access query into Excel using a command button on an Access form in the following way I describe below. Below you will find the simple query I am...
3
by: =?Utf-8?B?YzY3NjIyOA==?= | last post by:
Hi all, I have a question for you. I have a .csv file which has many lines of data. Each line has many data fields which are delimited by ",". Now I need to extract part of data from this...
19
by: cj2 | last post by:
#1 Is there a quick way to export a datatable to an excel file? Or delimited file? #2 Where is the appropriate Microsoft monitored group to ask about writing reports in SQL Reporting services...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.