DoCmd.SendObject crashing Access

darthcalis

Registered User.
Local time
Today, 08:13
Joined
Mar 20, 2012
Messages
17
Yep, exactly what it says in the heading. Anyone have a clue as to why this would happen?

Not used SendObject before so all I wrote was a tiny bit of test code which runs from a command button. The send object line is:

Code:
DoCmd.SendObject acSendReport, strSendObjectName, acFormatPDF, strEmailAddTo, , strEmailAddFrom, _
    strSubject, strBody

And the strings are just all test values, but contain genuine e-mail addresses etc. But as soon as this runs, Access goes into 'Not Responding' state and then boom, down she goes!

Am I missing something?

Emilio
 
Last edited:
It can happen when trying to export a corrupted object.
 
Ah, ok. Odd thing is that I only created a test report with a single unbound control on it into which I wrote a bit of data. Seems unlikely it would be corrupt.

Could it be that something else in the database is corrupt other than the object being sent? It wouldn't surprise me if something was corrupt, I have had several problems over the past couple of weeks with code / macros that were working perfectly and untouched suddenly not working. It's right pain to fix.
 
Last edited:
The body of the message is limited to 255 characters but I expect it would complain rather than crash if this was exceeded.

Have you tried exporting in other formats instead of pdf?

Regarding the corruption it might be worth trying a decompile. This reverts any compiled code to its source code.
 
The message body was just a few words so it didn't exceed the limit.

I didn't try another format, no, but when I did the same thing happened - weird. I have managed to see it work the first time on opening the database, but on subsequent attempts, it crashes.

I do decompile the code on a regular basis, however this doesn't always work. I had a problem where running compact and repair seemed to 'lock' some corruption into the code - it was very strange. Basically some completely unrelated function stopped working due to the fact that I used the character '¦' as a delimiter in a constant. Attempting to use the version of the database that was created after the compact and repair was stuck in a corrupted state. Simply removing the offending character from the version before the C&R worked fine. I'm a bit wary of using C&R now, but I do decompile regularly.

Having said all this, I've spend the day building myself some VBA functions to do lots of e-mail related stuff and that all works fine so I have got round my problem that way. It is still odd though. I think I will come back to investigating it when I have a bit more time to spare.
 
Last edited:

Users who are viewing this thread

Back
Top Bottom