DoCmd Code

I'm wanting to insert data, in this case and employee's name from query1, 
into the text of an email.  Can anyone tell me how this is done.  I've 
provide some sample code below.  Many thanks!

Function SendEmail()

DoCmd.SendObject acSendQuery, "Query1", "HTML", "John Doe", , , "Adherence", _
"The following agent (Query1.[Employee Name]) is out of adherence"

End Function

0
Utf
1/23/2008 2:26:02 PM
access 16762 articles. 3 followers. Follow

2 Replies
996 Views

Similar Articles

[PageSpeed] 50

you can use DLookup() but there may be a better way depending on how you are 
running this code.  For example, how are you deriving the "John Doe" name?

DoCmd.SendObject acSendQuery, "Query1", "HTML", "John Doe", , , "Adherence", 
_
 "The following agent  & " DLookup("[Employee Name]", "Query1", "some where 
string that resolves to a single record") & " is out of adherence"

BTW - change your query names to something meaningful.  Don't leave them as 
the default names.

"Stan" <Stan@discussions.microsoft.com> wrote in message 
news:9FF4F860-4F4C-4A51-83CC-D04227C1A111@microsoft.com...
> I'm wanting to insert data, in this case and employee's name from query1,
> into the text of an email.  Can anyone tell me how this is done.  I've
> provide some sample code below.  Many thanks!
>
> Function SendEmail()
>
> DoCmd.SendObject acSendQuery, "Query1", "HTML", "John Doe", , , 
> "Adherence", _
> "The following agent (Query1.[Employee Name]) is out of adherence"
>
> End Function
> 


0
Pat
1/23/2008 4:07:29 PM
Many thanks Pat.  That worked.

"Pat Hartman" wrote:

> you can use DLookup() but there may be a better way depending on how you are 
> running this code.  For example, how are you deriving the "John Doe" name?
> 
> DoCmd.SendObject acSendQuery, "Query1", "HTML", "John Doe", , , "Adherence", 
> _
>  "The following agent  & " DLookup("[Employee Name]", "Query1", "some where 
> string that resolves to a single record") & " is out of adherence"
> 
> BTW - change your query names to something meaningful.  Don't leave them as 
> the default names.
> 
> "Stan" <Stan@discussions.microsoft.com> wrote in message 
> news:9FF4F860-4F4C-4A51-83CC-D04227C1A111@microsoft.com...
> > I'm wanting to insert data, in this case and employee's name from query1,
> > into the text of an email.  Can anyone tell me how this is done.  I've
> > provide some sample code below.  Many thanks!
> >
> > Function SendEmail()
> >
> > DoCmd.SendObject acSendQuery, "Query1", "HTML", "John Doe", , , 
> > "Adherence", _
> > "The following agent (Query1.[Employee Name]) is out of adherence"
> >
> > End Function
> > 
> 
> 
> 
0
Utf
1/23/2008 7:20:03 PM
Reply:

Similar Artilces:

HTML code fragment #2
I just purchased Pub 2002 and cannot copy/paste anything into the HTML Code fragment box. The only thing that happens is a little box pops up and says what's this?. And, of course, what's this msg says I can type or paste-but won't work. I can type into the box, but I'd rather use the cut/paste method. any thoughts? Thanks. You have to use Ctrl + V to paste. DavidF "paddlefoot" <paddlefoot@discussions.microsoft.com> wrote in message news:9AE872AA-F49F-41EA-993D-DD9E4435914B@microsoft.com... >I just purchased Pub 2002 and cannot copy/paste anyth...

Exchange error code 0x8004010f
i had installed exchange server 2003 ,and its qorking quite normally but as i send and receive my emails on client end i receive an error code thats says "Task 'Microsoft Exchange Server' reported error (0x8004010F) : 'The operation failed. An object could not be found." This is an error related to Problem downloading offline address book.what version of Outlook is being used .is it Outlook 2003 and used in cached mode? If yes , then removed the cached mode option from Outlook 2003 and try again doing send /receive . Check out this kb article : http://support.mi...

STOP codes 0x0000000A, 0x000000D1, 0x000000CE
Five days ago, my computer was working fine. I didn't install anything new, or purposely update anything either. Suddenly though, the internet stopped working after I got a BSOD and the STOP code 0x000000CE. However, the internet worked fine in safe mode, and it still works fine in safe mode. In an attempt to fix my computer, I ran several anti-virus programs, like Ad-Aware, Spybot, Norton, SmitFraudFix and Avast. Nothing worked. I tried clearing the Winsock thingy with netsh (I forget exactly how it worked), to no avail. As a sidenote, the internet also works fine on a com...

HELP! VBA Code Stopping on Open
I have a database that, when opened, launches a form (via Display Form/Page in Startup…). For some inexplicable reason the code stops/breaks at the On Open event and the VBA editor displays. I can’t figure out why this is happening, it has not happened in the past and this database has been in use for quite some time. There is NO code break set and the break only happens once, when the form is opened for the first time. If I select F5 the code runs and the form opens. If I close the form and then reopen it (manually by double clicking on it) the form opens without stopping a...

color code holidays?
I have Outlook 2003 and am attempting to color code Birthday's & Holiday's is that possible? Thanks in advance! Right click on one of them in the calendar and select automatic formatting. Use the ensuing window to set your conditions and colors. I edited the default color labels for the calendar to have one for Holidays, Birthdays, Sports and Entertainment, and for Recurring events. --� Milly Staples [MVP - Outlook] Post all replies to the group to keep the discussion intact. After searching google.groups.com and finding no answer: Matt <nutshell222@hotmail.com> aske...

Hooking pictures to code
I have a html code for a picture viewer thing and I need to get publisher to find the pictures that I need. If you know where I need to put the pictures to make it work I would be very appreciative. Justin, Huh? Is the picture viewer thing a 3rd Party Album? If it is, you need to follow the instructions for using it or at least post which album viewer it is. Then you would create a link to it in Pub, using either text or an image. I think. Mike Justin wrote: > I have a html code for a picture viewer thing and I need to get publisher to > find the pictures that I need. If ...

generate .NET code from visio 2003
Hi ! How can i Generate .NET code from a UML made in visio 2003 ? I did searh the net and found this link but it says 404 ? http://msdnaa.net/Resources/Display.aspx?ResID=1949 the article title is Generating .NET Code Using Visio Enterprise Architect's UML So any one know how do that or any one have back up copy of this article Thanks which version of v2003 are you using. The EA version which comes with vs.net I believe has the process in the help facility. v2003 pro does not support forward engineering of uml... Al "Suhail Kaleem" <suhailkaleem@mailyoulike.com>...

Help with code #2
What I am trying to do is have a macro lookup cell b1 from sheets21 to sheet120 and when it finds the first sheet that this cell is blank to execute a macro. I used to use the code below but it is way to long over this many sheets. If Sheet21.Range("AV3") = "" Then Sheet21.Select Else If Sheet22.Range("AV3") = "" Then Sheet22.Select Else If Sheet23.Range("AV3") = "" Then Sheet23.Select Else etc. Thanks Greg Greg, You can do the following, although it has a problem that I'll describe: dim s as worksheet for each s in ...

Pure HTML Formatting in Javascript Code
Has anyone know how to code in javascript for mailto code with the HTML formatting to clients (not in ASP/PHP/.NET coding, normal HTML coding only)? I'm trying to send a tell-a-friend form with referee emails attached to the bcc field. However, I need to know how to send a HTML email through this email.... I've open the Outlook correctly however, it seems that the Outlook that I open with the code display in rich text formatting instead of HTML formatting though I'm not specifying anything for the formatting in the code. Here is the snippet of the code: ------------------------...

change the code to be a formula
i have the following code added to the s/s tab which does what i want but is there a way of adding this to cell like a formula thing like vlookup?? Option Explicit Private Sub Worksheet_Change(ByVal Target As Range) If Target.Cells.Count > 1 Then Exit Sub If Target.Column = 2 Then If Target.Value = "" Then Exit Sub Application.EnableEvents = False Target.Value = Worksheets("Station").Range("A1") _ .Offset(Application.WorksheetFunction _ .Match(Target.Value, Worksheets("Station").Range("StationList"), 0), 0) Application.Ena...

Problem With Code...Still
I posted a message earlier and been trying to figure out why this code doesn't work right. Thank you for all your help. Private Sub CommandButton6_Click() Dim message As String Set MyComputer = CreateObject("Scripting.FileSystemObject") FolderName1 = Range("F6") FileName1 = Range("M6") If MyComputer.FolderExists(FolderName1) = False Then message = MsgBox("The directory: " & FolderName1 & ", does not exist." & Chr(10) _ & "Enter a new directory path (cell F6).", 0, ...

copy code into all open wkbks
How do I copy a code that I want to use and store it in "all open workbooks', instead of on the open worksheet only You can put it in another workbook and then just make sure that this other workbook is open when you need the code. Lots of people who need this functionality, put their code into a workbook named personal.xls and then save that personal.xls into their XLStart folder. By placing the personal.xls workbook there, it's opened each time you start excel. nkeiru wrote: > > How do I copy a code that I want to use and store it > in "all open workbooks&...

Remove Exchange fails with error code 0x80072030
Hello Situation: Exchange Org spanning multiple domains with 4 Exchange Server running. Two servers are running Exchange 2003, two servers are running 2000. Problem: When I try to uninstall an Exchange 200 server I receive an error with code 0x80072030. I do not encounter the issues described in KB article 287172. Exchange Setup Log contains the following information: [13:52:17] ScPRQ_ServerIsNotHomeServerForPostmasterOfNonEmptyOrg (K:\admin\src\udog\excommon\prereq.cxx:2683) Error code 0X80072030 (8240): There is no such object on the server. [13:52:17] CCompServer::S...

Unhiding All hidden Worksheets with a Macro/VBA Code
Hi, Can anyone help me please ? Whilst working with an Excel Workbook I often hide all unwanted Worksheets leaving only the ones I need to work on visible. What I would like to do is have a macro or VBA code to click on a button to unhide all hidden worksheets rather repeating Format-Sheet-Unhide to unhide each worksheet. Any help would be greatly appreciated (Excel version Excel 2000) Many thanks Rob -- robertguy 44 Married two kids ------------------------------------------------------------------------ robertguy's Profile: http://www.excelforum.com/member.php?action=getinf...

Bar code tracking of fixed assets
is there a solution available for Great Plains that allows you to track fixed assets by a bar code? ---------------- This post is a suggestion for Microsoft, and Microsoft responds to the suggestions with the most votes. To vote for this suggestion, click the "I Agree" button in the message pane. If you do not see the button, follow this link to open the suggestion in the Microsoft Web-based Newsreader and then click "I Agree" in the message pane. http://www.microsoft.com/Businesssolutions/Community/NewsGroups/dgbrowser/en-us/default.mspx?mid=1ff0b670-3408-4021-9705-...

RMS should provide for different supplier item code
Along with using the ITEM LOOKUP CODE field to store barcodes for scanning products, there should be one or two fields for an alternative lookup code. This would allow retailers to prepare purchase orders using supplier's native information, which is most times a more recognisable format than a barcode number string. It also allows a store to utilise their internal coding system without having to re-memorise and re-learn item codes. Descriptions cannot always narrow down an item to a specific one. isn't this what the alias table is for? There needs to be a field for the supplie...

Code in certain sheets
Hello I have a file with 33 sheets and a VB code (below) in "This Workbook". The problem is that I don't want the first and last sheets obey this code. How can I fix this problem? This is code: Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range) If Not Application.Intersect(Target, Range("A7:A68")) Is Nothing Then If IsNumeric(Target.Value) Then Application.EnableEvents = False Target = Left(Format(Target.Value, "0000"), 2) & ":" & _ Right(Format(Target.Value, "0000"), 2) Application.EnableEven...

VBA code to "skip" empty rows
This code will take text from column A in an Excel Work sheet and insert it into column B inside a text box. I would like to “tweek” this to skip over the code that creates the text boxes on each row that contains empty text. The result I seek is to have a text box created with text copied from column A and no text box created when column A is empty. My attempt to do this myself is not working out. I am just starting to learn something about VBA. Any comments for a better approach to solve this would be appreciated. I have commented out my attempt to skip past the textbox...

Working on Code from a VB Book; Help Interpreting Errors
I found the example of code in a book: Public Class Form1 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim drives() As String drives = System.IO.Directory.GetLogicalDrives Dim iDrive As Integer DrivesList.Items.Clear() On Error Resume Next For iDrive = 0 To drives.GetUpperBound(0) DrivesList.Items.Add(drives(iDrive)) Next DrivesList.SelectedIndex = 1 End Sub Private Sub DrivesList_SelectedIndexChanged(ByVal sender As System.O...

zip code credit card verification POS v2.0
Posting this as a separate suggestion as existing posts are for RMS. This is specifically for POS (not RMS): Suggest Microsoft work with their "recommended" mechant service providers to provide the capability to qualify credit card transactions with zip code verification. After reviewing the fees on my bill that my mechant services provider was charging, they recommended using zip code verification to reduce my charges/rates. MS technical support confirmed that MS POS does NOT support this feature. This puts MS POS as a disadvantage over competitve point of sale systems and cau...

KB976098 won't install. Error code 800F0900, unknown error
Windows update fails to install KB976098. Also tried manually to install with same failing result. Windows update did install KB970653 on 8/23/09. "Tgray" wrote: > Windows update fails to install KB976098. Also tried manually to install > with same failing result. Windows update did install KB970653 on 8/23/09. I use Windows 7, 64 bit version. Update KB976098 gets into an eternal update loop every time. It never finishes, not even after a full night waiting. If I then press sleep or hybernate, the system continues updating when I restart again and I ...

DoCmd.OpenReport
Can someone please help me get the " and ' right for this? (PARTNUMBER is a text field). I just can't get it...argh! DoCmd.OpenReport stDocName, acPreview, , "[PARTNUMBER] =" ' "& Me.PARTNUMBER" ' " DoCmd.OpenReport stDocName, acPreview, , "[PARTNUMBER] =""" & Me.PARTNUMBER & """" -- Duane Hookom Microsoft Access MVP "Gina K" wrote: > Can someone please help me get the " and ' right for this? (PARTNUMBER is a > text field). I just can't get it...argh! >...

Code does not work on merged cells #2
My apologies if my post wasn't too clear, let me try to explain again - Throughout my spreadsheet I have cells with Data Validation where you select from a drop down list. These cells are then "Merged and Centered" with the cell immediately to its right - so cell B3 is merged and centered with C3. In my code, if I add B3 - the code doesn't work. I have tried B3:C3 and even tried naming the cell and using the name. Thanks -- fuzzyfreak ------------------------------------------------------------------------ fuzzyfreak's Profile: http://www.excelforum.com/member.p...

DoCmd.ApplyFilter problem
I have an OnClick event that does the following: DoCmd.ApplyFilter , "[TicketNo] = " & Me!GetTicket TicketNo is a column in my bound table and GetTicket is a textbox on the form. When I enter a value in the textbox and click the command button, the code works and I get the requested recond on the form. When I call the command button Click() procedure from other code, however, I get a prompt for parameter [TicketNo], the ApplyFilter is failing. I have moved a valid value to GetTicket control. Does anyone have a clue why this is happening? -- Dorian "Give someone...

Run Code in General Module Upon Activation of Other Sheets
I have VBA code residing in a general module of a workbook. The outpu from the code updates several sheets in the workbook. I would like t automatically Run the code in the general module if any of thes several sheets are activated (by clicking on the sheet�s tab). How ca I do this? Thanks -- Message posted from http://www.ExcelForum.com Hi Steve You can use the folowwing events in the sheet module(not a normal module) Right click on a sheet tab and choose view code. Paste the events in there and press Alt-Q to go back to Excel. You can copy the code in the event or type the macro name ...