single record in SendObject

CoachPhil

Registered User.
Local time
Today, 06:00
Joined
Jun 24, 2008
Messages
83
How might I generate a single record from a report using SendObject?
 
Either the report has to filter itself via a criteria in the query or code in the open event, or you can first open the report using OpenReport with a wherecondition and then SendObject will send the filtered report.
 
pbaldy, i have tried the criteria in the query, code in the open event, but not the where condition in the Openreport, I will give that a try.
Thank you
 
No problem; post back if you get stuck. I'm surprised those methods didn't work though.
 
pbaldy,

I cannot wrap my mind around this, the OpenReport did not work either;

DoCmd.RunCommand acCmdSaveRecord
DoCmd.OpenReport sDocName, acViewPreview, [RequestNo]=Forms![LeaveRequestForm]![Text2]
DoCmd.SendObject acSendReport, sDocName, acFormatSNP, sToName, sCCName,,"Leave Request", sSubject,,False

???
 
Is the report filtered? The syntax is off plus I think you have the wherecondition in the wrong place. Try:

DoCmd.OpenReport sDocName, acViewPreview, , "[RequestNo]=" & Forms![LeaveRequestForm]![Text2]

Here's a reference on using the wherecondition (forms and reports are basically the same in this regard):

http://www.baldyweb.com/wherecondition.htm
 
Thanks pbaldy, been a long week. I will make that work on Monday. I appreciate your time.
 
Paul,

No, there is no filter on the Report, should there be? and even with the changes I am receiving the comment"no record to save" ???
 
What I mean is that the OpenReport line should be opening the report filtered to the request number on the form. Is it? Can you post the db?
 
Paul,

Sorry, I cannot post, our system security will not allow it. I will beat at it a while longer on my own.

thanks again
 
I understand. The theory is that the OpenReport line opens a filtered report because of the wherecondition. As long as that report is still open, the SendObject line will send the filtered report (it would send an unfiltered report otherwise). I was trying to make sure the OpenReport line was properly opening a filtered report as part of the debugging process.
 
Paul,

good call, the OpenReport is not firing.

strWhere = "[RequestNo] =" & Me.Text2
Docmd.OpenReport "LeaveRequestReport", acViewPreview,,strWhere

no filter on the Form but a filter on the Report.

I have done OpenReport many times before and never run into trouble like this.
 
It's not firing, or not filtering? Set a breakpoint and make sure the value of Text2 is correct. What is the data type of RequestNo in the table?
 
Paul, the data type is autonumber, the value in Text2 is accurate. I tied everything to the table (form and report) and it worked, so I will have to review my query. Any tips appreciated.
 
I'm annoyed to say I'm stumped. I use the wherecondition method all the time, and yours looks correct for a numeric data type. You get no error, the report opens, but is not filtered to the selected RequestNo?
 
Hey Coach,

When the report is run next can you tell us what value is in the "Filter" field on the Form Properties page?

To get this, after the report has opened go to desgin view on this and look at the second tab from the left second line down.

If this info is not getting in there correctly this may be bugging the command to send the report to email.

HTH
 

Users who are viewing this thread

Back
Top Bottom