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
7 2016
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 -
Function mcrEmailClosure()
-
On Error GoTo mcrEmailClosure_Err
-
dim RptNum as string
-
-
RptNum = dlookup("[Report#]","qryClosure")
-
-
' Email as SNP closure report
-
DoCmd.SendObject acReport, "rptCloseOut",
-
"SnapshotFormat(*.snp)",
-
"", "", "", "Closure Report - Concern Number" & RptNum, "Please see attached
-
closure report", True, ""
-
-
mcrEmailClosure_Exit:
-
Exit Function
-
-
mcrEmailClosure_Err:
-
MsgBox Error$
-
Resume mcrEmailClosure_Exit
-
-
End Function
-
If you have criteria, you just need to add it to the Dlookup line
J
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
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
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.
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
Thanks a lot for your help. Everything worked fine and I owe it all to you.
Thanks a lot for your help. Everything worked fine and I owe it all to you.
Happy to help.
J
Sign in to post your reply or Sign up for a free account.
Similar topics
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...
|
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...
|
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...
|
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...
|
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....
|
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...
|
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...
|
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
"""
|
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...
|
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...
|
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...
|
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
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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...
|
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,...
|
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: 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...
| |