DoCmd AfterUpdate Error

gittymoe

Board Regular
Joined
Apr 23, 2005
Messages
79
Hi guys, I am having a little bit of trouble getting my DoCmd to execute properly. I am quite new to running code thru event procedures so I'll do my best to explain.


I am needing a query to run and then requery and then email that query to a known email address. Below is what I have come up with and it works up until it trys to send an email and I receive an error message "Run-Time Error '2995': Unknow message recipient(s); the message was not sent."

I have dummied the email address for obvious reasons but it is correct. My guess is that I have a comma or space out of place but just not sure?


Private Sub Text26_AfterUpdate()
Dim stDOCName As String

stDOCName = "qry SVE PURCHASE ORDERS + APPROVAL + TRANSIT RPT by vendor"
DoCmd.OpenQuery stDOCName, acNormal, acEdit
DoCmd.Requery

DoCmd.SendObject acSendQuery, "qry SVE PURCHASE ORDERS + APPROVAL + TRANSIT RPT by vendor", acFormatXLS, _
"MichaelJordan@domain.com", _
"Test Spreadsheet", "Test subject", "This is my message", , False


End Sub
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
After playing around after I posted I have figured out my error just as you described....however, my new issues has now become the following error.

"DB can't save the output data to the file you've selected" In doing some reasearch it seems to want to save and close the query before allowing to send an email?

Private Sub Text26_AfterUpdate()
Dim stDOCName As String

stDOCName = "qry SVE PURCHASE ORDERS + APPROVAL + TRANSIT RPT by vendor"
DoCmd.OpenQuery stDOCName, acNormal, acEdit
DoCmd.Requery
'DoCmd.Close acForm, "qry SVE PURCHASE ORDERS open by vendor1", acSaveYes
'DoCmd.Close acForm, "qry SVE PURCHASE ORDERS + APPROVAL + TRANSIT RPT by vendor", acSaveYes

DoCmd.SendObject acSendQuery, "qry SVE PURCHASE ORDERS + APPROVAL + TRANSIT RPT by vendor", acFormatXLS, _
"MichaelJordan@domain.com", , , "Test Subject", "Test Message Text", True, False



End Sub
 
Upvote 0
There is no need to run the query as you have done.?
Sending the object runs the query at that time.

Also if you have to have such a long query name, why not just use stDocname instead of the name as you have defined it

Rich (BB code):
DoCmd.SendObject acSendQuery,stDocName ......
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,214
Messages
6,170,771
Members
452,353
Latest member
strainu

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top