473,903 Members | 5,705 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Need Help with Code to Email from Form

I have a form in Access 97 on which I have an unbound list box filled
with our employees names from tblEmployees. When you select an
employee's name and click a button, the following code is run and
another form opens with only that employee's data:

For Each varSelected In Me!EmpList.Item sSelected
strSQL = strSQL & Me!EmpList.Item Data(varSelecte d) & ","
Next varSelected
If strSQL <> "" Then
strSQL = "[Employees].[EmployeeNumber] IN (" & Left(strSQL,
Len(strSQL) - 1) & ")"
DoCmd.OpenForm "frmVacationWee ks", acViewNormal, , strSQL

I have a textbox on the frmVacationWeek s called txtEmail. I need to
be able to click a button on this form that will automatically email a
report called rptApprovedVac only to the employee whose email address
is in txtEmail. I will appreciate any help you can give me on this.

Thanks,
JD
Nov 12 '05 #1
5 4489
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Use the SendObject method of the DoCmd object - see the help topic
SendObject.

- --
MGFoster:::mgf
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBP4r3LIechKq OuFEgEQImNQCfdi YZ016v8h9UTnT7R LkD6ov7174An06V
PIPy/+g6D/TKrSfAe9jPhwqS
=JzP/
-----END PGP SIGNATURE-----

jd****@yahoo.co m wrote:
I have a form in Access 97 on which I have an unbound list box filled
with our employees names from tblEmployees. When you select an
employee's name and click a button, the following code is run and
another form opens with only that employee's data:

For Each varSelected In Me!EmpList.Item sSelected
strSQL = strSQL & Me!EmpList.Item Data(varSelecte d) & ","
Next varSelected
If strSQL <> "" Then
strSQL = "[Employees].[EmployeeNumber] IN (" & Left(strSQL,
Len(strSQL) - 1) & ")"
DoCmd.OpenForm "frmVacationWee ks", acViewNormal, , strSQL

I have a textbox on the frmVacationWeek s called txtEmail. I need to
be able to click a button on this form that will automatically email a
report called rptApprovedVac only to the employee whose email address
is in txtEmail. I will appreciate any help you can give me on this.

Thanks,
JD


Nov 12 '05 #2
jd****@yahoo.co m (jd****@yahoo.c om) wrote in message news:<75******* *************** ****@posting.go ogle.com>...
I have a form in Access 97 on which I have an unbound list box filled
with our employees names from tblEmployees. When you select an
employee's name and click a button, the following code is run and
another form opens with only that employee's data:

For Each varSelected In Me!EmpList.Item sSelected
strSQL = strSQL & Me!EmpList.Item Data(varSelecte d) & ","
Next varSelected
If strSQL <> "" Then
strSQL = "[Employees].[EmployeeNumber] IN (" & Left(strSQL,
Len(strSQL) - 1) & ")"
DoCmd.OpenForm "frmVacationWee ks", acViewNormal, , strSQL

I have a textbox on the frmVacationWeek s called txtEmail. I need to
be able to click a button on this form that will automatically email a
report called rptApprovedVac only to the employee whose email address
is in txtEmail. I will appreciate any help you can give me on this.

Thanks,
JD


Either use the SendObject command or automate Outlook. (If you're
only mailing to one person at a time, why are you using a listbox?)
You could just loop through the ItemsSelected collection of the
listbox and inside the loop use SendObject command. Nothing doing.
Nov 12 '05 #3
pi********@hotm ail.com (Pieter Linden) wrote in message news:<bf******* *************** ***@posting.goo gle.com>...

Either use the SendObject command or automate Outlook. (If you're
only mailing to one person at a time, why are you using a listbox?)
You could just loop through the ItemsSelected collection of the
listbox and inside the loop use SendObject command. Nothing doing.


I developed a Vacation database and I am using the listbox on a form
that has several options - when an employee's name is selected in the
listbox, one can view and print reports with only that employee's
data, and open a form on which the employee can post dates he wants to
take off from work. On another form, after an employee's name is
selected in the listbox, the supervisor can approve or reject dates
the employee has requested to take off. It is on this form that I
need a button I can have the supervisors click to automatically email
the employee whose name appears on the form. I used SendObject, but
when I used this, I had to manually type the employee's name in the
"To" line of message box. My boss wants this automated - he doesn't
want the supervisors to have to type the employee's name. Any
suggestions?

Thanks,
JD
Nov 12 '05 #4
jd****@yahoo.co m (jd****@yahoo.c om) wrote in message news:<75******* *************** ****@posting.go ogle.com>...
pi********@hotm ail.com (Pieter Linden) wrote in message news:<bf******* *************** ***@posting.goo gle.com>...

Either use the SendObject command or automate Outlook. (If you're
only mailing to one person at a time, why are you using a listbox?)
You could just loop through the ItemsSelected collection of the
listbox and inside the loop use SendObject command. Nothing doing.


I developed a Vacation database and I am using the listbox on a form
that has several options - when an employee's name is selected in the
listbox, one can view and print reports with only that employee's
data, and open a form on which the employee can post dates he wants to
take off from work. On another form, after an employee's name is
selected in the listbox, the supervisor can approve or reject dates
the employee has requested to take off. It is on this form that I
need a button I can have the supervisors click to automatically email
the employee whose name appears on the form. I used SendObject, but
when I used this, I had to manually type the employee's name in the
"To" line of message box. My boss wants this automated - he doesn't
want the supervisors to have to type the employee's name. Any
suggestions?

Thanks,
JD

Say you have a combobox or a listbox with two columns. One shows the
employee's name, and the other shows the employee's e-mail address.
Then you could just pass the proper column value to the SendObject
function, and you should be ready to go. Something kinda like this...
without all the message box rubbish (just to check that I can see all
this stuff...)

Private Sub Command4_Click( )
Dim strName As String
Dim strEMail As String

strName = Me.List2.Column (0)
strEMail = Me.List2.Column (1)

MsgBox "Name: " & strName & vbCrLf & "E-Mail:" & strEMail,
vbOKOnly
DoCmd.SendObjec t acSendReport, "In House for Pickup",
acFormatHTML, strEMail, , , "See attached Report", "Like my report?"
End Sub

Column(0) is visible (width is non-zero)
Column(1) is not visible (width=0)

Then you just grab the e-mail addresses from a query or table...

SELECT FName & " " & LName As StaffName, EMailAddress
FROM Staff
ORDER BY FName, LName;

or whatever you want...

HTH,
Pieter
Nov 12 '05 #5
jd****@yahoo.co m (jd****@yahoo.c om) wrote in message news:<75******* *************** ****@posting.go ogle.com>...
pi********@hotm ail.com (Pieter Linden) wrote in message news:<bf******* *************** ***@posting.goo gle.com>...

Either use the SendObject command or automate Outlook. (If you're
only mailing to one person at a time, why are you using a listbox?)
You could just loop through the ItemsSelected collection of the
listbox and inside the loop use SendObject command. Nothing doing.


I developed a Vacation database and I am using the listbox on a form
that has several options - when an employee's name is selected in the
listbox, one can view and print reports with only that employee's
data, and open a form on which the employee can post dates he wants to
take off from work. On another form, after an employee's name is
selected in the listbox, the supervisor can approve or reject dates
the employee has requested to take off. It is on this form that I
need a button I can have the supervisors click to automatically email
the employee whose name appears on the form. I used SendObject, but
when I used this, I had to manually type the employee's name in the
"To" line of message box. My boss wants this automated - he doesn't
want the supervisors to have to type the employee's name. Any
suggestions?

Thanks,
JD


Addendum to above post: I modified my code in the OnClick event of the
button on my form to the following (thanks to someone in this NG):
DoCmd.SendObjec t acSendReport, "rptReportName" , "Snapshot Format",
Me.txtEMail, , , "Subject", "Message Body." This keeps me from having
to type in the employee's name - I just have to click Send when the
message box pops up, but I still need to automate this so it happens
in the background and the user needs to do nothing but click the
button. Thanks in advance for any tips.

JD
Nov 12 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
8768
by: Jim | last post by:
Hi, I keep getting form results emailed to me that would indicate a form from my web site is getting submitted with all fields blank or empty, but my code should preventing users from proceeding if they left any field blank. My guess is that someone is trying to hack the site using the form to gain entry or run commands -- I don't really know since I'm not a hacker. I just know that forms are often susceptible to these kinds of...
2
2941
by: Mike Button | last post by:
Hello all, I am really really desperate on what I should do, and I am asking for help from anyone in this newsgroup, here's the situation: I am creating a form that is being run on a server where there is no scripts allowed running (the software is from Opentext called Livelink)- therefore I need javascript to do the tasks listed below: 1. validate the form - this has been completed 2. pop up another window that will go ahead and...
19
4129
by: James Fortune | last post by:
I have a lot of respect for David Fenton and Allen Browne, but I don't understand why people who know how to write code to completely replace a front end do not write something that will automate the code that implements managing unbound controls on forms given the superior performance of unbound controls in a client/server environment. I can easily understand a newbie using bound controls or someone with a tight deadline. I guess I need...
4
10160
by: usl2222 | last post by:
Hi folks, I appreciate any assistance in the following problem: I have a form with a bunch of dynamic controls on it. All the controls are dynamically generated on a server, including all the validators. The user enters the data, presses OK. My OK button is dynamically generated as well, with some code-behind logic in
3
4623
by: mcse4u | last post by:
I would like to be able to add a hyperlink to the posted form below that automatically creates a hyperlink of the email address of the person submitting the form. Can someone please help me with the code I need to add? <%@language=vbscript%> <%option explicit dim fromMail
17
2092
by: freemann | last post by:
Can anyone provide example code showing how to send form results to a results page, email and a comma delimited file? Notice that I need it going to all three locations. Details: I have forms created and working. The first form the user fills out and submits. The form properties are set to Send to other: "Custom ISAPI, NSAPI, CGI, OR ASP SCRIPTING. The method is "POST" and the action is "secondpage.asp". I had to go this route because...
9
2205
by: MrHelpMe | last post by:
Hello again experts, I have successfully pulled data from an LDAP server and now what I want to do is drop the data into a database table. The following is my code that will insert the data but that has problems. FullName=Request.Form("Name") Email=Request.Form("Email") GivenName=Request.Form("GivenName")
14
4390
by: confusedfusion | last post by:
Not sure how many form submissions that have been lost over the years before I started but the company has a contact form that the required fields when validation fails the error message is going into the URL string on a refresh of the form page. I am very green on CF and CFM files and have this code below; I need to help for the error messages to "pop up" in a new window or display on the body of the page so anyone filling out the form knows...
3
2219
by: ibeehbk | last post by:
Hi. I have a form made in xhtml. I test via vbscript to make sure none of the fields are empty and properly formatted (ie email). All the regular fields work. However, I have two drop down menus that are SELECT elements (javascript-- one named arrivalcity and one named returncity). Basically they ask for a departure and return city and another menu appears with options based on that city. I can't seem to get the input from these fields in the...
0
9999
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9847
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10875
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10986
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
8049
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7206
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
6093
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4727
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4308
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.