Insert Form Field in a Module

D

Dave Couch

I have a module that sends an email with a message the "Proposal XXX has been
added" I want the XXX to be the field "ProposalNumber" from my open form
"SetupNewProposal". What is the syntax for adding this to the string??

Dave
 
F

fredg

I have a module that sends an email with a message the "Proposal XXX has been
added" I want the XXX to be the field "ProposalNumber" from my open form
"SetupNewProposal". What is the syntax for adding this to the string??

Dave

Why didn't you simply include this in your previous message? <g>
And it would have been better had you actually included your code,
otherwise I'm just guessing this will work. Anyway, this is what I
would use.

In the sub procedure name:

What is the datatype of [ProposalNumber]? Number?
Sub SendEmail(TheNumber as Integer)

If it is Text, then:
Sub SendEmail(TheNumber as Text)

In the procedure you can then use the value TheNumber as you would any
declared variable.

In your form, you would send the value to the sub procedure using:

SendEmail([ProposalNumber])
 
D

Dave Couch

Fred, I didn't think the 2 were directly related. Anyway, I got the
procedure to run just fine, thank to your help. However, I have not figured
out how to add the ProposalNumber Filed to the message. Here is the code:

Dim objoutlook As Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
Dim objOutlookRecip As Outlook.Recipient
Dim objOutlookAttach As Outlook.Attachment

'On Error GoTo ErrorMsgs

' 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. Substitute
' your names here.
Set objOutlookRecip = .Recipients.Add("(e-mail address removed)")
objOutlookRecip.Type = olTo
' Add the CC recipient(s) to the message.
' Set the Subject, Body, and Importance of the message.
.Subject = "New Proposal Added"
.Body = "A New Proposal has been added." & vbCrLf & vbCrLf
' Resolve each Recipient's name.
For Each objOutlookRecip In .Recipients
If Not objOutlookRecip.Resolve Then
objOutlookMsg.Display
End If
Next
.Send
End With
Set objOutlookMsg = Nothing
Set objoutlook = Nothing
Set objOutlookRecip = Nothing
Set objOutlookAttach = Nothing
'ErrorMsgs:
'If Err.Number = "287" Then
'MsgBox "You clicked No to the Outlook security warning. "
'Else
'MsgBox Err.Number, Err.Description
'End If
End Sub

In the line ".Body = "..." I want to it to say "Proposal Number" XXX "has
been added." The XXX would be replaced with a text field from the open Form
"NewProposalEntry" and the Field name of "ProposalNumber".

I just can't figure out how to reference the filed value within the text
string. Any help would be appreciated. Thanks again for the first answer.

Dave


fredg said:
I have a module that sends an email with a message the "Proposal XXX has been
added" I want the XXX to be the field "ProposalNumber" from my open form
"SetupNewProposal". What is the syntax for adding this to the string??

Dave

Why didn't you simply include this in your previous message? <g>
And it would have been better had you actually included your code,
otherwise I'm just guessing this will work. Anyway, this is what I
would use.

In the sub procedure name:

What is the datatype of [ProposalNumber]? Number?
Sub SendEmail(TheNumber as Integer)

If it is Text, then:
Sub SendEmail(TheNumber as Text)

In the procedure you can then use the value TheNumber as you would any
declared variable.

In your form, you would send the value to the sub procedure using:

SendEmail([ProposalNumber])
 
F

fredg

Fred, I didn't think the 2 were directly related. Anyway, I got the
procedure to run just fine, thank to your help. However, I have not figured
out how to add the ProposalNumber Filed to the message. Here is the code:

Dim objoutlook As Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
Dim objOutlookRecip As Outlook.Recipient
Dim objOutlookAttach As Outlook.Attachment

'On Error GoTo ErrorMsgs

' 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. Substitute
' your names here.
Set objOutlookRecip = .Recipients.Add("(e-mail address removed)")
objOutlookRecip.Type = olTo
' Add the CC recipient(s) to the message.
' Set the Subject, Body, and Importance of the message.
.Subject = "New Proposal Added"
.Body = "A New Proposal has been added." & vbCrLf & vbCrLf
' Resolve each Recipient's name.
For Each objOutlookRecip In .Recipients
If Not objOutlookRecip.Resolve Then
objOutlookMsg.Display
End If
Next
.Send
End With
Set objOutlookMsg = Nothing
Set objoutlook = Nothing
Set objOutlookRecip = Nothing
Set objOutlookAttach = Nothing
'ErrorMsgs:
'If Err.Number = "287" Then
'MsgBox "You clicked No to the Outlook security warning. "
'Else
'MsgBox Err.Number, Err.Description
'End If
End Sub

In the line ".Body = "..." I want to it to say "Proposal Number" XXX "has
been added." The XXX would be replaced with a text field from the open Form
"NewProposalEntry" and the Field name of "ProposalNumber".

I just can't figure out how to reference the filed value within the text
string. Any help would be appreciated. Thanks again for the first answer.

Dave

fredg said:
I have a module that sends an email with a message the "Proposal XXX has been
added" I want the XXX to be the field "ProposalNumber" from my open form
"SetupNewProposal". What is the syntax for adding this to the string??

Dave

Why didn't you simply include this in your previous message? <g>
And it would have been better had you actually included your code,
otherwise I'm just guessing this will work. Anyway, this is what I
would use.

In the sub procedure name:

What is the datatype of [ProposalNumber]? Number?
Sub SendEmail(TheNumber as Integer)

If it is Text, then:
Sub SendEmail(TheNumber as Text)

In the procedure you can then use the value TheNumber as you would any
declared variable.

In your form, you would send the value to the sub procedure using:

SendEmail([ProposalNumber])

Gee, you left out the procedure name.

From my reply to your original post>>>>>

****************
In the sub procedure name:

What is the datatype of [ProposalNumber]? Number?
Sub SendEmail(TheNumber as Integer)

If it is Text, then:
Sub SendEmail(TheNumber as Text)
*****************

Simply concatenate TheNumber into your text.

..Body = "Proposal Number " & TheNumber & " has been added." &
vbCrLf & vbCrLf
 
D

Dave Couch

Thanks Fred. I guess I just needed a refresher on concantation. Got
everything working. Thanks again,

Dave

fredg said:
Fred, I didn't think the 2 were directly related. Anyway, I got the
procedure to run just fine, thank to your help. However, I have not figured
out how to add the ProposalNumber Filed to the message. Here is the code:

Dim objoutlook As Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
Dim objOutlookRecip As Outlook.Recipient
Dim objOutlookAttach As Outlook.Attachment

'On Error GoTo ErrorMsgs

' 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. Substitute
' your names here.
Set objOutlookRecip = .Recipients.Add("(e-mail address removed)")
objOutlookRecip.Type = olTo
' Add the CC recipient(s) to the message.
' Set the Subject, Body, and Importance of the message.
.Subject = "New Proposal Added"
.Body = "A New Proposal has been added." & vbCrLf & vbCrLf
' Resolve each Recipient's name.
For Each objOutlookRecip In .Recipients
If Not objOutlookRecip.Resolve Then
objOutlookMsg.Display
End If
Next
.Send
End With
Set objOutlookMsg = Nothing
Set objoutlook = Nothing
Set objOutlookRecip = Nothing
Set objOutlookAttach = Nothing
'ErrorMsgs:
'If Err.Number = "287" Then
'MsgBox "You clicked No to the Outlook security warning. "
'Else
'MsgBox Err.Number, Err.Description
'End If
End Sub

In the line ".Body = "..." I want to it to say "Proposal Number" XXX "has
been added." The XXX would be replaced with a text field from the open Form
"NewProposalEntry" and the Field name of "ProposalNumber".

I just can't figure out how to reference the filed value within the text
string. Any help would be appreciated. Thanks again for the first answer.

Dave

fredg said:
On Fri, 7 Nov 2008 15:10:02 -0800, Dave Couch wrote:

I have a module that sends an email with a message the "Proposal XXX has been
added" I want the XXX to be the field "ProposalNumber" from my open form
"SetupNewProposal". What is the syntax for adding this to the string??

Dave

Why didn't you simply include this in your previous message? <g>
And it would have been better had you actually included your code,
otherwise I'm just guessing this will work. Anyway, this is what I
would use.

In the sub procedure name:

What is the datatype of [ProposalNumber]? Number?
Sub SendEmail(TheNumber as Integer)

If it is Text, then:
Sub SendEmail(TheNumber as Text)

In the procedure you can then use the value TheNumber as you would any
declared variable.

In your form, you would send the value to the sub procedure using:

SendEmail([ProposalNumber])

Gee, you left out the procedure name.

From my reply to your original post>>>>>

****************
In the sub procedure name:

What is the datatype of [ProposalNumber]? Number?
Sub SendEmail(TheNumber as Integer)

If it is Text, then:
Sub SendEmail(TheNumber as Text)
*****************

Simply concatenate TheNumber into your text.

..Body = "Proposal Number " & TheNumber & " has been added." &
vbCrLf & vbCrLf
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top