Send Object with SQL statement

  • Thread starter Thread starter Tom Ross
  • Start date Start date
T

Tom Ross

Hi

I am using the SendObject method to send an email message to remind the QA
department of upcoming testing

DoCmd.SendObject , , , , , , "Internal Testing Needed for PO " &
Me.cmbProjectID & "-" & Me.PONum & " ", "Please check internal testing
reports for requirements of this purchase order ", False

That works fine. I would like to send the results of a query using values
from the form in that same message. I want to generate the query with an
SQL statement using controls on the form

"SELECT LineItems.ProjectID, LineItems.PONum, LineItems.ItemNum,
LineItems.InternalTest FROM LineItems WHERE projectid = '" &
Me.cmbProjectID "'"

Is there a way to put attach the results of this SQL query as spreadsheet
table or anything. The sendobject method wanted a name of a query and did
not accept an SQL statement

Thanks

Tom.
 
You can put the sql into a named query and use that. I suggest
just creating one query and using that over again, rather than
creating a new query each time:

currentdb.querydefs("qrySendTo").sql = strSQL
docmd.sendobject .....

(david)
 
A named query and then change that query from code before using it. I was
not even thinking in that direction

Thanks

ps How do I indicate Excel file in the output option I tried "Microsoft
Excel" "*.xls" is there a constant that does that
 
For XLS, use the named constant acFormatXLS, which is a
text constant with the value "Microsoft Excel (*.xls)"

I notice that on my PC, I can't do this using a Macro
Action -- I don't know if that is significant.

(david)
 
Back
Top