Filter for DoCmd.SendObject acSendReport

Sydcomebak

Registered User.
Local time
Today, 03:31
Joined
Apr 14, 2008
Messages
46
This works:
Code:
Private Sub Command127_Click()
DoCmd.SendObject acSendReport, "MLS_Report", acFormatPDF, "", , , "", , True
End Sub
But I end up with a 53 page .PDF of all 53 listings. I only want 1, but I don't know where to put the filter...
Code:
Private Sub Command127_Click()
  sWHERE = "Listings.ID = " &[Listings.ID].Value
  DoCmd.SendObject acSendReport, "MLS_Report", acFormatPDF, "", , , "", , True
End Sub
Any help would be great!

Thanks!
 
There is no Where condition in the SendObject method. What you need to do, is put the use the criteria Forms!YourFormName!YourControlName in the query that you are using to populate your Report.
 
So I already need to be in the report that I want to send? I can't send it from a continuous form?
 
If you use; Forms!YourFormName!YourControlName this will filter the Query/Report to the record that currently holds focus in the form. You could use; Like Nz(Forms!YourFormName!YourControlName, "*") to account for situations where no selection has been made in the form in which case all records of the report would be printed/sent.
 
I have a button in a continuous form "Listings - Edit" than onclick:
Code:
Private Sub Command127_Click()
DoCmd.SendObject acSendReport, "MLS_Report", acFormatPDF, "", , , "", , True
End Sub
In the same form, to view the same report and paper print it, I filter by:
Code:
sWHERE = "Listings.ID = " &[Listings.ID].Value
The Report Query Builder looks like this:
Code:
Field:       ID
Table:       Listings
Sort:        
Show:        {Checked}
Criteria:
or:

I understand that you want me to set the criteria, and I get what I want if I enter a single # for testing, like '5'.

Given what I've posted, can you hash out what needs to be typed in criteria?
 
Crap, now I'm noticing that everything inn't populating from the Report_Load()... That makes the button useless...
 

Users who are viewing this thread

Back
Top Bottom