single record in SendObject (1 Viewer)

CoachPhil

Registered User.
Local time
Today, 07:32
Joined
Jun 24, 2008
Messages
83
How might I generate a single record from a report using SendObject?
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 07:32
Joined
Aug 30, 2003
Messages
36,127
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.
 

CoachPhil

Registered User.
Local time
Today, 07:32
Joined
Jun 24, 2008
Messages
83
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
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 07:32
Joined
Aug 30, 2003
Messages
36,127
No problem; post back if you get stuck. I'm surprised those methods didn't work though.
 

CoachPhil

Registered User.
Local time
Today, 07:32
Joined
Jun 24, 2008
Messages
83
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

???
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 07:32
Joined
Aug 30, 2003
Messages
36,127
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
 

CoachPhil

Registered User.
Local time
Today, 07:32
Joined
Jun 24, 2008
Messages
83
Thanks pbaldy, been a long week. I will make that work on Monday. I appreciate your time.
 

CoachPhil

Registered User.
Local time
Today, 07:32
Joined
Jun 24, 2008
Messages
83
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" ???
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 07:32
Joined
Aug 30, 2003
Messages
36,127
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?
 

CoachPhil

Registered User.
Local time
Today, 07:32
Joined
Jun 24, 2008
Messages
83
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
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 07:32
Joined
Aug 30, 2003
Messages
36,127
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.
 

CoachPhil

Registered User.
Local time
Today, 07:32
Joined
Jun 24, 2008
Messages
83
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.
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 07:32
Joined
Aug 30, 2003
Messages
36,127
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?
 

CoachPhil

Registered User.
Local time
Today, 07:32
Joined
Jun 24, 2008
Messages
83
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.
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 07:32
Joined
Aug 30, 2003
Messages
36,127
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?
 

McSwifty

Registered User.
Local time
Tomorrow, 02:32
Joined
Jan 14, 2010
Messages
67
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

Top Bottom