A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

passing element within form to function. - 1 attachment



 
 
Thread Tools Display Modes
  #1  
Old September 30th, 2004, 06:26 PM
Steve
external usenet poster
 
Posts: n/a
Default passing element within form to function. - 1 attachment

I am presently trying to pass data, in a form, to a function
"SendEmailMessage" I've been able to get the main e-mail generation to work
fine but now I need to attach a file to each email I generate. As you can
see in the picture, when I press the [Send Email Message], I would like to
link the {Hyperlink to PCN Document}. Once I can send that link to my
"SendEmailMessage" macro, which in turn call the Function "SendEmail()"
(withing the module SendTheMessage)I'm set up to attach it to the generated
email.

Bottom line See Picture, I would like to pass the text string "C:\My
Documents\customers.txt" to the function SendEmail().

Thank you in advance

Steve



Attached Images
File Type: gif PCN Form.gif (42.3 KB, 14 views)
  #2  
Old September 30th, 2004, 10:28 PM
Douglas J. Steele
external usenet poster
 
Posts: n/a
Default

There was no need to attach the pictu it didn't help.

What's the name of the text box that's storing that text string? You refer
to its content as Me.nameoftextbo

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)



"Steve" wrote in message
. 50...
I am presently trying to pass data, in a form, to a function
"SendEmailMessage" I've been able to get the main e-mail generation to

work
fine but now I need to attach a file to each email I generate. As you can
see in the picture, when I press the [Send Email Message], I would like

to
link the {Hyperlink to PCN Document}. Once I can send that link to my
"SendEmailMessage" macro, which in turn call the Function "SendEmail()"
(withing the module SendTheMessage)I'm set up to attach it to the

generated
email.

Bottom line See Picture, I would like to pass the text string "C:\My
Documents\customers.txt" to the function SendEmail().

Thank you in advance

Steve




  #3  
Old October 4th, 2004, 05:55 PM
Steve
external usenet poster
 
Posts: n/a
Default

"Douglas J. Steele" wrote in news:u3Bu
:

There was no need to attach the pictu it didn't help.

What's the name of the text box that's storing that text string? You refer
to its content as Me.nameoftextbo


Thank you for your responce.

The name of the box is "Hyperlink". In the command22 (Button for Emailing)
properties, I set:

(On Click)
"=SendEmail(True,[me.hyperlink])"

Now... SendMail() is a Function as followed:

Option Compare Database
Option Explicit

Function SendEmail(DisplayMsg As Boolean, Optional AttachmentPath)
Dim objOutlook As Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
Dim objOutlookRecip As Outlook.Recipient
Dim objOutlookAttach As Outlook.Attachment

' Create the Outlook session.
Set objOutlook = CreateObject("Outlook.Application")

' Create the message.
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)

With objOutlookMsg
' Add the To recipient(s) to the message.
Set objOutlookRecip = ")
objOutlookRecip.Type = olTo

' Add the CC recipient(s) to the message.
Set objOutlookRecip = ")
objOutlookRecip.Type = olCC

' Add the BCC recipient(s) to the message.
' Set objOutlookRecip = ")
' objOutlookRecip.Type = olBCC

' Set the Subject, Body, and Importance of the message.
.Subject = "This PCN requires attention!"
.Body = "We will need to get in some samples of the new parts as
soon as possible for testing." & vbCrLf & vbCrLf + "Please advise on the
status as soon as you know."
.Importance = olImportanceHigh 'High importance

' Add attachments to the message.
If Not IsMissing(AttachmentPath) Then
Set objOutlookAttach = .Attachments.Add(AttachmentPath)
End If

' Resolve each Recipient's name.
For Each objOutlookRecip In .Recipients
objOutlookRecip.Resolve
Next

' Should we display the message before sending?
If DisplayMsg Then
.Display
Else
.Save
.Send
End If
End With
Set objOutlook = Nothing
End Function


Thank you for your time.

Steve
  #4  
Old October 4th, 2004, 11:25 PM
Douglas J. Steele
external usenet poster
 
Posts: n/a
Default

"Steve" wrote in message
...
"Douglas J. Steele" wrote in news:u3Bu
:

There was no need to attach the pictu it didn't help.

What's the name of the text box that's storing that text string? You

refer
to its content as Me.nameoftextbo


Thank you for your responce.

The name of the box is "Hyperlink". In the command22 (Button for

Emailing)
properties, I set:

(On Click)
"=SendEmail(True,[me.hyperlink])"


Try renaming the field. I would expect that Hyperlink is a reserved word.
And you don't need the square brackets.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)





  #5  
Old October 5th, 2004, 12:44 PM
Steve
external usenet poster
 
Posts: n/a
Default

"Douglas J. Steele" wrote in
:

"Steve" wrote in message
...
"Douglas J. Steele" wrote in
news:u3Bu :

There was no need to attach the pictu it didn't help.

What's the name of the text box that's storing that text string? You

refer
to its content as Me.nameoftextbo


Thank you for your responce.

The name of the box is "Hyperlink". In the command22 (Button for

Emailing)
properties, I set:

(On Click)
"=SendEmail(True,[me.hyperlink])"


Try renaming the field. I would expect that Hyperlink is a reserved
word. And you don't need the square brackets.


Okay,

I get the error...
"The object doesn't contain the Automation Object 'Me.'"

I feel as though I am making this more difficult than it really is.

Let's Start over....

The objective,
When I press the button [Send Email], I would like my function ran
with the form information (PCN_Hyperlink) {I renamed the Hyperlink
box}. Am I starting off wrong by running things through a Macro which
call the function? I may be having problems passing the information
through the macro and not going directly to my code. Here is what I
know...

Module name - SendTheMessage
Within SendTheMessage - function SendEmail(DisplayMsg,AttachmentPath)

Again, Thank you for your time.

And patience

Steve
  #6  
Old October 5th, 2004, 10:47 PM
Douglas J. Steele
external usenet poster
 
Posts: n/a
Default

"Steve" wrote in message
.. .
"Douglas J. Steele" wrote in
:

"Steve" wrote in message
...
"Douglas J. Steele" wrote in
news:u3Bu :

There was no need to attach the pictu it didn't help.

What's the name of the text box that's storing that text string? You

refer
to its content as Me.nameoftextbo


Thank you for your responce.

The name of the box is "Hyperlink". In the command22 (Button for

Emailing)
properties, I set:

(On Click)
"=SendEmail(True,[me.hyperlink])"


Try renaming the field. I would expect that Hyperlink is a reserved
word. And you don't need the square brackets.


Okay,

I get the error...
"The object doesn't contain the Automation Object 'Me.'"

I feel as though I am making this more difficult than it really is.

Let's Start over....

The objective,
When I press the button [Send Email], I would like my function ran
with the form information (PCN_Hyperlink) {I renamed the Hyperlink
box}. Am I starting off wrong by running things through a Macro which
call the function? I may be having problems passing the information
through the macro and not going directly to my code. Here is what I
know...

Module name - SendTheMessage
Within SendTheMessage - function SendEmail(DisplayMsg,AttachmentPath)



Can you tell where the error is occurring? Have you stepped through the
function? I never use macros, so I can't comment whether that may be causing
some of the problem.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)





  #7  
Old October 6th, 2004, 12:14 PM
Steve
external usenet poster
 
Posts: n/a
Default

Okay,

I get the error...
"The object doesn't contain the Automation Object 'Me.'"

I feel as though I am making this more difficult than it really is.

Let's Start over....

The objective,
When I press the button [Send Email], I would like my function ran
with the form information (PCN_Hyperlink) {I renamed the Hyperlink
box}. Am I starting off wrong by running things through a Macro
which call the function? I may be having problems passing the
information through the macro and not going directly to my code.
Here is what I know...

Module name - SendTheMessage
Within SendTheMessage - function SendEmail(DisplayMsg,AttachmentPath)



Can you tell where the error is occurring? Have you stepped through the
function? I never use macros, so I can't comment whether that may be
causing some of the problem.


When I stepped through the function and watching for the passed data to be
passed to the function, I get a varient/error so I defined it as a string.

I basically get a "" passed to that variable once it was assigned as a
string.

So, with that, I determained (correctly or incorrectly) the information
isn't being passed through the macro into the function.

I modified the macro to include "fixed" information. (actually typing in
the data within the macro definitions to include SendMail(True,"C:\My
Documents\Customers.txt")

I was still getting the same results.

Is there another way to pass the form field data directly to a function? I
tried

OpenModule within a new macro called SEM (send email)
Within OpenModule Macro, I called OpenModule

Within the definition for OpenModule, I entered

Module Name - SendTheEmail
Procedure Name - SendEmail(True,"C:\My Documents\Customers.txt")

I received that same results.

Thank you for to Extended time and help.


Steve
 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
VLOOKUP: Passing a Value to the Function News Reader Worksheet Functions 8 September 7th, 2004 12:47 AM
using a DSum() function in a form footer Paul James Using Forms 12 July 31st, 2004 05:06 AM
Display Parameter from Form on Report sara Setting Up & Running Reports 10 July 19th, 2004 04:54 PM
Unsafe Attachments Ron Installation & Setup 2 June 9th, 2004 01:55 AM


All times are GMT +1. The time now is 04:41 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.