|
-
Jun 19th, 2006, 08:53 AM
#1
Thread Starter
Hyperactive Member
[RESOLVED]Email with Access Macro or VBA?
I am using Access 2000 and trying to have it email a report after the user clicks on a button.
I used a macro on a previous program and it worked fine. However, in this new program it doesn't seem to be working entirely the same, and I think it's because I have a subform.
The macro is set up as such...
Action: Open Report
--Name: rptBuilder
--View: Print Preview
--Where Condition: [tblAccounts]![IncidentNum]=[Forms]![frmBldrNewAcct]![sfrmBldr]![txtIncidentNum]
Action: Send Object
--Type: Report
--Name: rptBuilder
--Format: Snapshot
--Email: [email protected]
On the form I have a hidden textbox which populates with an autonumber as soon as the user starts entering data for a new record. After the user enters all the data they click on a command button at the bottom of the screen which calls the macro shown above.
What happens with the macro is it opens a report I created and uses the Where Condition to use the "hidden autonumber" from the form to move focus in the table to that specific record they just entered so that information from the record is displayed in the report. A snapshot is taken and then emailed out.
The problem is after the button is clicked to email the data a window pops up asking for a parameter which is the autonumber. However, the user will never know the autonumber since that textbox is hidden and even if I show it I don't want the user to have to enter any parameter.
As I said before I used this same method on a previous program and everythign ran through perfect without it asking for any parameter. I "think" the reason it's asking now is because I have a subform on that form with the command button.
I tried the following two statements for the Where Condition but it still won't work the same. Anyone know what's going on? Or should I just use VBA, but I'm not sure how to email a report with VBA.
[tblAccounts]![IncidentNum]=[Forms]![frmBldrNewAcct]![sfrmBldr]![txtIncidentNum]
[tblAccounts]![IncidentNum]=[Forms]![sfrmBldr]![txtIncidentNum]
Last edited by lilmark; Jun 19th, 2006 at 11:17 AM.
-
Jun 19th, 2006, 09:01 AM
#2
Re: Email with Access Macro or VBA?
oh no.. dont use macros! they are EVIL! 
to send an email:
VB Code:
DoCmd.SendObject acSendReport, "rptName", , "TO here", "CC Here", "BCC Here", "Subject Here", "Message"
JPnyc rocks!! (Just ask him!)
If u have your answer please go to the thread tools and click "Mark Thread Resolved"
-
Jun 19th, 2006, 09:15 AM
#3
Thread Starter
Hyperactive Member
Re: Email with Access Macro or VBA?
I tried using the following code...
VB Code:
DoCmd.SendObject acSendReport, "rptBldrSvrSDNewAcct", acFormatDAP, " [email protected]"
acFormatDAP is for SnapShot, right?
But, I get an error message saying...
"The formats that enable you to output data as a Microsoft Excel, rich-text format, MS-DOS text, or HTML file are missing from the Windows Registry."
-
Jun 19th, 2006, 09:17 AM
#4
Re: Email with Access Macro or VBA?
what happens if u leave the format out?
JPnyc rocks!! (Just ask him!)
If u have your answer please go to the thread tools and click "Mark Thread Resolved"
-
Jun 19th, 2006, 09:21 AM
#5
Thread Starter
Hyperactive Member
Re: Email with Access Macro or VBA?
When I leave it out it asks me to select a format. I select SnapShot and click Ok.
Then, I get a window saying...
"Now outputting page 1 of Bldr Svc Rquest to a mail message"
page 2, page 3, page 4, page 5, page 6...it just keeps increasing slowly.
Looks like it's doing all the records in the table.
-
Jun 19th, 2006, 09:29 AM
#6
Re: Email with Access Macro or VBA?
acFormatSNP is snapshot...
as far as all the records...
you need to set the report to filter on load according to your criteria..
then do it
JPnyc rocks!! (Just ask him!)
If u have your answer please go to the thread tools and click "Mark Thread Resolved"
-
Jun 19th, 2006, 09:44 AM
#7
Thread Starter
Hyperactive Member
Re: Email with Access Macro or VBA?
I still get that same pop-up window asking me to input a parameter.
-
Jun 19th, 2006, 09:53 AM
#8
Re: Email with Access Macro or VBA?
a parameter for the output type?? or for the Report?
JPnyc rocks!! (Just ask him!)
If u have your answer please go to the thread tools and click "Mark Thread Resolved"
-
Jun 19th, 2006, 10:00 AM
#9
Thread Starter
Hyperactive Member
Re: Email with Access Macro or VBA?
The parameter it asks for is the hidden autonumber on the form which is the primary key for the table. It's for the report. If you look at my first post the Where Condition uses the hidden autonumber from the form so it displays that specific record on the report.
-
Jun 19th, 2006, 10:21 AM
#10
Re: Email with Access Macro or VBA?
in the report properties.. put the crieteria into the Filter Field..
or create a query that gives u the results, then use that query for the report
JPnyc rocks!! (Just ask him!)
If u have your answer please go to the thread tools and click "Mark Thread Resolved"
-
Jun 19th, 2006, 11:14 AM
#11
Thread Starter
Hyperactive Member
Re: Email with Access Macro or VBA?
Putting the code in the report's filter worked.
I love you man...
No...really...i love you
-
Jun 19th, 2006, 12:03 PM
#12
Re: [RESOLVED]Email with Access Macro or VBA?
glad to help
been there sooo many times myself!
JPnyc rocks!! (Just ask him!)
If u have your answer please go to the thread tools and click "Mark Thread Resolved"
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|