Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Problem with VB sendobject function filling in the email address in the To field

Posted on 2006-06-01
7
Medium Priority
?
244 Views
Last Modified: 2008-02-01
Hello all,

I have a form with a comand button (cmddisapproved) with an event on click. This is running the VB below:

DoCmd.SendObject acReport, "NTEGIssueLogRptNumber_testing_all", "RichTextFormat(*.rtf)", "[Query]![NTEGIssueLogQryNumber]![email]", "", "", "NTEG Issue # Disapproved" & [Forms]![frmNTEGIssuesLog_testing_all]![txtTicketNumber], "", False, ""

I am trying to use the query that runs the report listed above to pull the users email address from a table. When I run this code I get an error Run-time error 2295 unknown message recipient(s); the message was not sent.

Any help you can all give me would be greatly appreciated.

Thanks,
Jeff
0
Comment
Question by:woodje
  • 4
  • 2
7 Comments
 
LVL 5

Expert Comment

by:MageDribble
ID: 16807026
You could use a recordset before the DoCmd to return the value and store it into a String.  Then just put the string variable where you have [Query]!....
0
 
LVL 34

Expert Comment

by:jefftwilley
ID: 16807108
Try changing the "False" at the end to "True" so it opens the e-mail before sending it. Take a look at what's being placed into the "To" field. If it's not correct, then definately use Mage's solution to retrieve the e-mail address. A quick question, when you run the query to grab the e-mail address....is there more than one?
J
0
 

Author Comment

by:woodje
ID: 16807323
jeffwilley,

To answer your last question it is only one email addresss. As well when I change the false value to true it returns.

[Query]![NTEGIssueLogQryNumber]![email]

as the email address.

MageDribble,

Can you please elaberate on the recordset idea. I keep getting errors "object required" when I set the rst values.

Dim rst As recordset
Set rst = Query!NTEGIssueLogQryNumber!email
0
Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

 
LVL 5

Expert Comment

by:MageDribble
ID: 16807376
you can use an ADO command to access that query directly but they can be more complex.  Just type the SQL Code into the place I show below...

Dim rst as ADODB.recordset        ' This declares the object BUT......
Set rst = new ADODB.recordset   ' This actually creates the recordset object
Dim myEmailAddy as String

rst.open "Insert the SQL Code here", CurrentProject.Connection
myEmailAddy = rst.Fields(0)
rst.Close

DoCmd.SendObject acReport, "NTEGIssueLogRptNumber_testing_all", "RichTextFormat(*.rtf)", myEmailAddy, "", "", "NTEG Issue # Disapproved" & [Forms]![frmNTEGIssuesLog_testing_all]![txtTicketNumber], "", False, ""
0
 
LVL 5

Accepted Solution

by:
MageDribble earned 1000 total points
ID: 16807386
you can add a message box before the SendObject part to show you what the email address is:


msgbox "My Email addy is: " & myEmailAddy  ' This will show the email addy in a message box

DoCmd.SendObject acReport, "NTEGIssueLogRptNumber_testing_all", "RichTextFormat(*.rtf)", myEmailAddy, "", "", "NTEG Issue # Disapproved" & [Forms]![frmNTEGIssuesLog_testing_all]![txtTicketNumber], "", False, ""
0
 

Author Comment

by:woodje
ID: 16807494
MageDribble,

I have inserted the SQL code below. And I am getting an error that I am missing an operator.

SELECT tblSecurity.email
FROM tblNTEGIssuesLog INNER JOIN tblSecurity ON tblNTEGIssuesLog.Initiator = tblSecurity.UserName
WHERE (((tblNTEGIssuesLog.TroubleTicketNumber)=[Forms]![frmNTEGIssuesLog_testing_all]![txtTicketNumber]));
0
 
LVL 5

Expert Comment

by:MageDribble
ID: 16838627
change your WHERE clause to this

WHERE tblNTEGIssuesLog.TroubleTicketNumber = Forms!frmNTEGIssuesLog_testing_all!txtTicketNumber
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Instead of error trapping or hard-coding for non-updateable fields when using QODBC, let VBA automatically disable them when forms open. This way, users can view but not change the data. Part 1 explained how to use schema tables to do this. Part 2 h…
Sometimes MS breaks things just for fun... In Access 2003, only the maximum allowable SQL string length could cause problems as you built a recordset. Now, when using string data in a WHERE clause, the 'identifier' maximum is 128 characters. So, …
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses

581 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question