Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Email problem with a report 1

Status
Not open for further replies.

madvalpreston

Technical User
Apr 7, 2011
142
GB
HI



I have a report that is run froma quote form and as 2 buttons, one for report preview and one for email... In both cases I always want to print/email the one report for that particual quote, so I f Quote number 1 is on screen then thats all that should appear....... It is based on Survey types....



1. The code here previews the report and this works fine and only brings up the right result.

StDocName = "quotedem"

DoCmd.OpenReport Combo38.Column(2), acPreview, , "type = '" & Combo38.Column(1) & "' AND IDquote = " & idquote

2. I now want to email this to a the client in an email and use the client email address.... the code below works to the point of the report itself



'DoCmd.SendObject acSendReport, Combo38.Column(2), acFormatPDF, cboQclientid.Column(3), , , "Asbestos Surveyors UK Quotation", , , "type = '" & Combo38.Column(1) & "' AND IDquote = " & idquote

What is happening is, if a survey type as more than one quote (example combination as 2 quote records) then the report shows the full 2 reports instead of just the one (like the preview does in number 1)...



I have tried all sorts to the code but I cannot figure out how to email just the valid quite that is active



Does anyone have any ideas how I can do this



Thanks
 
docmd.sendobject cannot take a filter / criteria like docmd.openreport.

Since you are only getting the type now it sounds like the query under the report is set to use the type as a value from the form.

In any case the way to get this to work is to make the query for the report use the values on the form as criteria and not use filters in code.

If your query is used for multiple things, you might need to copy it so you have a report only version. Once your report is set to use an appropriate query, in the queries design view on the criteria line you can right click and click build. This will bring up a window that you can select the form and control on it to use as criteria.

I hope that was clear enough as my note is a little hurried... Good luck.
 
Hi

Thanks for the reply.

The report is based on a query already, so when it opens it looks at the query and of course draws information from this.

Do you know of a way around this at all, it is very frustrating.

I need it to email the one report only to the email address in the cboQclientid.Column(3).

it seems impossible but surely access 2010 should be able to deal with this...

Thanks
 
What I meant before is you need to make your query under the report you are opening or sending use criteria based on the form values rather than passing criteria to report via code because this is not supported for sendobject (at least in Access 2003).

You do that by putting the query in design view and on the criteria line for the appropriate column (type or idquote) right click and select build. In window that opens should allow you to drill through the forms in the left pane to the control in the center pane that has the data you want to use. Click ok.

You should have a something in the criteria line that looks like Forms!FormName!IDquote if you selected data or Forms!FormName!txtIDquote if you selected the control.
 
Hi
Please excuse my ignorance on this. I really dont quite understand you, could you give me an idiots guide to this if possible.....

Thanks
 
Hi Lameid

My brain finnally started working and I tried what you said on the query. Did not work so good at first, so i went into the report and went to data source , opened the query from there and then did your suggestion in the quoteid criteria.... and it works.

Thank you so much, this as frustrated me all week and now it works so a big thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top