473,395 Members | 1,948 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,395 software developers and data experts.

E-mail macro

Hi,

I am a beginner with Access but I have managed to play around with VB and macros.

I have a query called "qryClosure". In this database, I have fields like Report #, Customer #, CA Resp, Defect Code etc.... and only ONE record. This query is linked to the report called rptCloseout and Report # from qryClosure is in this report. Now what I want to do is when I send a snapshot of this report to someone using the macro, I want to include this report # in the subject or filename without typing it in. Basically what I want the macro to do is to take the info (report #) from the qryClosure file -- > Report # field and put that number in the subject or filename.

Here is the code that I got along with the macro

Option Compare Database

'------------------------------------------------------------
' mcrEmailClosure
'
'------------------------------------------------------------
Function mcrEmailClosure()
On Error GoTo mcrEmailClosure_Err

' Email as SNP closure report
DoCmd.SendObject acReport, "rptCloseOut",
"SnapshotFormat(*.snp)",
"", "", "", "Closure Report - Concern Number", "Please see attached
closure report", True, ""

mcrEmailClosure_Exit:
Exit Function

mcrEmailClosure_Err:
MsgBox Error$
Resume mcrEmailClosure_Exit

End Function
---------------------------------------------------------------------------*-----------------------

Any ideas? Thanks
May 10 '07 #1
7 2016
JConsulting
603 Expert 512MB
I am attaching some more files to give a better idea of what i am trying to do.
If there's no criteria for your query..then you can do this

Expand|Select|Wrap|Line Numbers
  1. Function mcrEmailClosure()
  2. On Error GoTo mcrEmailClosure_Err
  3. dim RptNum as string
  4.  
  5. RptNum = dlookup("[Report#]","qryClosure")
  6.  
  7. ' Email as SNP closure report
  8. DoCmd.SendObject acReport, "rptCloseOut",
  9. "SnapshotFormat(*.snp)",
  10. "", "", "", "Closure Report - Concern Number" & RptNum, "Please see attached
  11. closure report", True, ""
  12.  
  13. mcrEmailClosure_Exit:
  14. Exit Function
  15.  
  16. mcrEmailClosure_Err:
  17. MsgBox Error$
  18. Resume mcrEmailClosure_Exit
  19.  
  20. End Function
  21.  
If you have criteria, you just need to add it to the Dlookup line
J
May 10 '07 #2
Does this lookup function copy the report # from the query and put it in the subject line? I'll be testing your code tomorrow to see how it works and i'll report back to you. Thanks

Here is a picture of the query if it helps.

Thanks for your help
Attached Images
File Type: jpg query.JPG (66.4 KB, 273 views)
May 10 '07 #3
JConsulting
603 Expert 512MB
Does this lookup function copy the report # from the query and put it in the subject line? I'll be testing your code tomorrow to see how it works and i'll report back to you. Thanks

Here is a picture of the query if it helps.

Thanks for your help
Like I said, if your criteria has no crietria...then yes.
J
May 10 '07 #4
Hi
Your code works. Thanks a lot.

One more thing. Can you please tell me how I can convert a module into a macro. The previous version of the code I gave you came from the macro which I converted to VB. In the macro, I had the option to select the action called SendObject and fill up the parameters.
Now I want to create a button in the toolbar to execute this code. If you can tell me that, that would be awesome.

Thanks for your help.
May 10 '07 #5
JConsulting
603 Expert 512MB
Hi
Your code works. Thanks a lot.

One more thing. Can you please tell me how I can convert a module into a macro. The previous version of the code I gave you came from the macro which I converted to VB. In the macro, I had the option to select the action called SendObject and fill up the parameters.
Now I want to create a button in the toolbar to execute this code. If you can tell me that, that would be awesome.

Thanks for your help.
You can create a macro to run your code using the Run Code option.

If your function for example is called RunBob, then where it asks you what the name of the code is....put RunBob()

That should take care of it.

Make sure your converted macro is defined as a function, and in a public module. If it's in a form module for example then if it's not public..it won't find it.

J
May 10 '07 #6
Thanks a lot for your help. Everything worked fine and I owe it all to you.
May 10 '07 #7
JConsulting
603 Expert 512MB
Thanks a lot for your help. Everything worked fine and I owe it all to you.
Happy to help.
J
May 10 '07 #8

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

Similar topics

25
by: Andrew Dalke | last post by:
Here's a proposed Q&A for the FAQ based on a couple recent threads. Appropriate comments appreciated X.Y: Why doesn't Python have macros like in Lisp or Scheme? Before answering that, a...
699
by: mike420 | last post by:
I think everyone who used Python will agree that its syntax is the best thing going for it. It is very readable and easy for everyone to learn. But, Python does not a have very good macro...
4
by: Bob | last post by:
I'm running Access 97 and have a sub-form within a main form. The subform allows data entry by the user. Now, I would also like to enter a row from a macro, but when I try, the entry always goes...
3
by: scott_baird | last post by:
I have an email macro setup (maybe I should go another way, but that was the quickest at the moment...) and what I would like to do is automate the "to" addressee of the email it generates for...
7
by: Newbie_sw2003 | last post by:
Where should I use them? I am giving you my understandings. Please correct me if I am wrong: MACRO: e.g.:#define ref-name 99 The code is substituted by the MACRO ref-name. So no overhead....
5
by: Bill | last post by:
This database has no forms. I am viewing an Access table in datasheet view. I'd like to execute a macro to execute a function (using "runcode"). In the function, I'll reading data from the record...
37
by: junky_fellow | last post by:
hi guys, Can you please suggest that in what cases should a macro be preferred over inline function and viceversa ? Is there any case where using a macro will be more efficient as compared to...
14
by: amit.man | last post by:
Hello i need to write a MACRO function that look something like this """ do_somthing(); for(int i=0;i<100;i++) {do_something_else())} return(somthing_other_then_those()) // a double type """
7
by: skillzero | last post by:
Is there a way to cause a compile/preprocessor error in a macro if a preprocessor symbol is not defined? I want to do the equivalent of this in a macro: #if( !defined( SOME_FLAG ) ) #error not...
16
by: mdh | last post by:
I have asked a few questions about Macros...and think what I have been missing ...and which all who have replied clearly understand...is that this is a Pre-processor action. Hopefully the above is...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.