SendObject to include a field

J

JNariss

Hello,

I am almost done creating this form with the send object command.
However everything works great accept when the form is submitted it
tells me my code is incorrect and the field I am referring to is not
found.

My code is:

Private Sub Submit_Approval_Click()
Dim strTo As String
Dim strRequest_ID As String
Dim strMessage As String

strTo = Me.Analyst_Email
strRequest_ID = Me!Request_ID
strMessage = "You have been choosen as the Analyst for a System Change
Request. Please go to the database at
\\egsrosintra1\d$\Database\SystemChangeRequest.mdb and choose Reports -
View By --> View By Request ID" & Chr$(13) & Chr$(13) & _
"Request ID: " & stRequest_ID & Chr$(13) & Chr$(13) & _
"Please do not reply to this automated email."

I have a field in my form called Request ID. However this is connected
to another table so I feel like I am missing something here which is
probably why it won't populate the strRequest_ID properly. My Request
ID comes from my table called Request.

Do I have to do something like: =
.[Request.Request_ID]

or what???

Please help me............I know I almost have it!!!

I have tried to use strRequest_ID = Me.Request_ID but that will only
populate an email with a message body that includes: Request ID:
and no ID number which is sopposed to be shown to the person
receiving the email.

Thanks,
Justine
 
A

Arvin Meyer [MVP]

Build a recordset, find the value and assign it to a public variable that
you can use in the SendObject method:
Set a reference to DAO, then (aircode):

Public strRequest As String

Sub MySub()
Dim db As DAO.Database
Dim rst As DAO.Recordset

Set db = CurrentDb
Set rst = db.OpenRecordset("Select * From MyTable Where Request_ID =" &
Me.txtID)

strRequest = rst![Request_ID]

End Sub
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads
http://www.datastrat.com
http://www.mvps.org/access
 
J

JNariss

I'm sorry, I'm following but I not. Do I add the code you provided in
with my Private Sub Submit_Approval_Click()
code or is this something separate? And is the code you provided the
exact code I will be using except for the line:

Set rst = db.OpenRecordset("Select * From MyTable Where Request_ID =" &

Me.txtID)

I would change to: Set rst = db.OpenRecordset("Select * Request =" &
Me.txtID)

The original table the Request ID comes from is called Request.

Thanks for yor help,
Justine
 

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