473,761 Members | 3,187 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Change Private Function to Public Sub/Function

I have and email button on one of my forms but I want to use that code
on a few more forms but don't want to copy the code on each form
because any changes I make to the code will need to be updated on each.
I was thinking I could use a Public Module so I can call it from
anywhere but I get the following error: External Name not defined.

It looks like it is not finding the Participant First Name from my
form. Here is my code. How can I fix this? I basically just want to
call the procedure from any form.

Public Sub SendMail()
On Error GoTo Err_cmdEmail:

'Provides the Send Mail automation
Dim dbs As DAO.Database
Dim strSubject As String
Dim strEmailAddress As String
Dim strCCEmail As String
Dim strEMailMsg As String
strSubject = "Employment verification for:" & " " & [Participant First
Name] & " " & [Participant Last Name] & " " & ", Please respond- 6
Month Check"
strEmailAddress = "em********@123 .com"
strBCCEmail = [SupervisorEmail] & "; " & [HRContactFax] &
"@faxmail.c om; " & [HRContactEmail]

Set dbs = CurrentDb
strEMailMsg = "Written Request for Employment Verification." _
& Chr(10) & "Today's Date:" & " " & Date & Chr(10) & Chr(10) _
& "Re:" & " " & [Participant First Name] & " " & [Participant Last
Name] & Chr(10) & Chr(10) & "Hello," _
& Chr(10) & Chr(10) & "The below information is currently on record
for:" & " " & [Participant First Name] & " " & [Participant Last Name]
_
& Chr(10) & Chr(10) & "Employer: " & " " & [OrganizationNam e] _
& Chr(10) & "Job Title: " & " " & [Job Description] _
& Chr(10) & "Pay Rate: " & " $" & [Starting Pay] & Chr(10) &
"Status (Full or Part time): " & " " & [Hours] _
& Chr(10) & "Start Date: " & " " & [BeginDate] _
& Chr(10) & Chr(10) & "To verify this information please do one of
the following:" _
& Chr(10) & Chr(10) & "1. Have Human Resources, or the immediate
supervisor make any changes or" _
& "correction s and return this letter via email or fax to Company
Name along with the Supervisor's " _
& "name and full contact information. Email: em********@123. com
Fax:" _
& Chr(10) & Chr(10) & "2. Fax a copy of the most recent paycheck
stub to (123) 456-7891. " _
& "Please make sure that the above information, Employee Name,
Company Name, Job Title, Pay Rate, " _
& "and Hours per week are included on or with the paycheck stub." _
& Chr(10) & Chr(10) & "I would greatly appreciate your response as
soon as possible but no later " _
& "than (Date). Keeping our information current enables us to keep
the terms of our grant contracts " _
& "and ensures that we will continue to receive the grants and
resources that make Company Name possible. Thanks for your help! " _

'EMAIL USER DETAILS & ATT REPORT
DoCmd.SendObjec t , , html, strEmailAddress , _
, strBCCEmail, strSubject, strEMailMsg, True, False
Err_cmdEmail:

If Err.Number = 2295 Then
MsgBox "There are no email addresses for the Supervisor or HR
Contact. The email message was not generated. Enter in valid email
addresses and try again.", _
vbInformation, "Email Message Can Not be Sent."

End If

End Sub

Thanks

Aug 31 '06 #1
1 3613
mchlle wrote:
I have and email button on one of my forms but I want to use that code
on a few more forms but don't want to copy the code on each form
because any changes I make to the code will need to be updated on each.
I was thinking I could use a Public Module so I can call it from
anywhere but I get the following error: External Name not defined.

It looks like it is not finding the Participant First Name from my
form. Here is my code. How can I fix this? I basically just want to
call the procedure from any form.
You might want to pass the form or form name to the proc
So...
Public Sub SendMail(frm As Form)
would be the first thing.

Then use
frm![Participant Last Name]
when referencing the field
>
Public Sub SendMail()
On Error GoTo Err_cmdEmail:

'Provides the Send Mail automation
Dim dbs As DAO.Database
Dim strSubject As String
Dim strEmailAddress As String
Dim strCCEmail As String
Dim strEMailMsg As String
strSubject = "Employment verification for:" & " " & [Participant First
Name] & " " & [Participant Last Name] & " " & ", Please respond- 6
Month Check"
strEmailAddress = "em********@123 .com"
strBCCEmail = [SupervisorEmail] & "; " & [HRContactFax] &
"@faxmail.c om; " & [HRContactEmail]

Set dbs = CurrentDb
strEMailMsg = "Written Request for Employment Verification." _
& Chr(10) & "Today's Date:" & " " & Date & Chr(10) & Chr(10) _
& "Re:" & " " & [Participant First Name] & " " & [Participant Last
Name] & Chr(10) & Chr(10) & "Hello," _
& Chr(10) & Chr(10) & "The below information is currently on record
for:" & " " & [Participant First Name] & " " & [Participant Last Name]
_
& Chr(10) & Chr(10) & "Employer: " & " " & [OrganizationNam e] _
& Chr(10) & "Job Title: " & " " & [Job Description] _
& Chr(10) & "Pay Rate: " & " $" & [Starting Pay] & Chr(10) &
"Status (Full or Part time): " & " " & [Hours] _
& Chr(10) & "Start Date: " & " " & [BeginDate] _
& Chr(10) & Chr(10) & "To verify this information please do one of
the following:" _
& Chr(10) & Chr(10) & "1. Have Human Resources, or the immediate
supervisor make any changes or" _
& "correction s and return this letter via email or fax to Company
Name along with the Supervisor's " _
& "name and full contact information. Email: em********@123. com
Fax:" _
& Chr(10) & Chr(10) & "2. Fax a copy of the most recent paycheck
stub to (123) 456-7891. " _
& "Please make sure that the above information, Employee Name,
Company Name, Job Title, Pay Rate, " _
& "and Hours per week are included on or with the paycheck stub." _
& Chr(10) & Chr(10) & "I would greatly appreciate your response as
soon as possible but no later " _
& "than (Date). Keeping our information current enables us to keep
the terms of our grant contracts " _
& "and ensures that we will continue to receive the grants and
resources that make Company Name possible. Thanks for your help! " _

'EMAIL USER DETAILS & ATT REPORT
DoCmd.SendObjec t , , html, strEmailAddress , _
, strBCCEmail, strSubject, strEMailMsg, True, False
Err_cmdEmail:

If Err.Number = 2295 Then
MsgBox "There are no email addresses for the Supervisor or HR
Contact. The email message was not generated. Enter in valid email
addresses and try again.", _
vbInformation, "Email Message Can Not be Sent."

End If

End Sub

Thanks
Aug 31 '06 #2

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

Similar topics

4
15519
by: pjac | last post by:
I need some help with some VB language that will change the screen resolution on a monitor when a MS-Access 2000 database is opened from 1024 x 768 to 800 x 600. Any help with this effort would be deeply appreciated. Thanks in advance....
8
8502
by: lauren quantrell | last post by:
Is there a way to force a change in a user's screen resolution using VBA code without having any input from the user? Example: User John Backwards has his screen set to 800 x 600 pixels. Backwards loads an Access app that needs at least 1024 x 768 pixels so the app, on load, changes the screen resolution for him to 1024 x 768.
0
1451
by: MS | last post by:
Is the schema used to validate XML Documentation Comments available to be changed by a VS.Net user? I suspect the this question is no so have a couple of requests: 1.) I use #region extensively along with the Outlining key functions to organize and navigate my code. In general, having an uncatagorized list of undifferentiated declarations in the generated HTML documentation is not all that helpful. Please have VS.Net do one of the...
7
1344
by: Peter Oliphant | last post by:
I use to make the statement that you could always replace any 'private' or 'public' access with 'public' and the code would still compile. This is no longer the case. It turns out that in /clr it is not allowed (as far as I can tell) to reduce the access of a virtual method defined in a base class. Thus, if one declares a virtual method in a base class as 'protected' and then proceeded to create derived classes with the virtual method...
3
12745
by: spielmann | last post by:
Hello I want to change the scrollbar size of windows, How can I do that with vb.net I have find this in VB6 but how can we convert simply this code. thx
0
2493
by: zeng.hui.stephen | last post by:
I download the demo http://msdn.microsoft.com/msdnmag/issues/02/10/cuttingedge/. I inherite the demo, and write my code. I want to use Hook to monitor C++ Edit change. I use a C# form containing a Edit(textbox) and button to test at first. When I change text in Edit or press button to setText value, I want to monitor the change event. But the event code always return 0, why?
1
6066
by: Sankalp | last post by:
Hi, I am using VB 2005. My application has many data bound controls. The connection is stored in the app.config file. I want the application to start with a default connection string and while during the runtime, the user can click on a button and change the connection string without exiting the application. I would really appreciate any sort of help.
9
9834
by: aleplgr | last post by:
Hi! I'm trying to let the end-user select the language of the menues I'm showing him. To do that I've got this Selector class that shows the end user a combo box, a label and a button. In the combo box the user selects the language (English,Spanish,French,..) and when he clicks in the button shows the label in the language selected. This works fine but it's just one form, I need to change the language of all the menues in an application, so...
0
1594
by: Composer | last post by:
More experienced programmers may laugh that I had to struggle with this, but I post it so that others in my position might benefit. My application allows the user to have many forms open. Some of the forms allow data items to be changed which should be reflected on other forms. I cannot predict which forms will be open nor how many of them. I just know that every time data item X is changed on forms 1 or 2, every occurrence of X on...
1
2620
by: chromis | last post by:
Hi, I've been trying to create a carousel class which takes an array of phrases and then creates a textfield for each one positioning it vertically based on the order it was added. The next stage would be for it to make the phrases move down the _y axis until they reach the limit of the container. The phrases need to then swap onto a container behind or drop depths so they are behind the other phrases and then make their way back up. The...
0
9538
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
9353
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
9975
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...
0
8794
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7342
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
6623
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
5241
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
3
3481
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2765
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.