code behind sendreport locking up

Blackwidow

Registered User.
Local time
Today, 04:04
Joined
Apr 30, 2003
Messages
149
I have a form with email addresses on to forward a report to a particular person. Code is below

Private Sub cmdMail7_Click()
On Error GoTo Err_cmdMail7_Click

Dim stDocName As String

stDocName = "rptConsPrint"
DoCmd.SendObject acReport, stDocName, acFormatSNP, "stottd@Collegeh.bham.sch.uk", , , "Consequence Issued", "SIBAL MESSAGE: The Attached Consequence has been issed. Please Log into Sibal and deal with this incident.", NO

Exit_cmdMail7_Click:
Exit Sub

Err_cmdMail7_Click:
MsgBox Err.Description
Resume Exit_cmdMail7_Click


The Problem I have is that this code will work once, but say I then send another report or indeed the same report to someone (Obviously using the above code on another button with a different email address) then it doesnt work, it just does nothing....

I cant understand why it will work once but not again, the only way to get it to work again is to log out and reload, which obviously is not the answer! It isnt coming up with an error message or anything, it just does nothing...

If anyone can help I would really appreciate it as this database is going live next week and I'll have to stall if I cant fix this
 
everything ok

Just found out that its a microsoft fault

to fix the problem you have to remove some characters from the message..
Alternatively there are various ways of fixing this problem SendObject Method Fails in Access 2000
 
just a quick question though... why not use the function in a more general way? you said you wanted to send the same report to a different email address. I guess you are doing so by copying all the code again and changing the address?

why not instead do

Code:
Private Function sendReport(email As String)
On Error GoTo Err_cmdMail7_Click

Dim stDocName As String

stDocName = "rptConsPrint"
DoCmd.SendObject acReport, stDocName, acFormatSNP, email, , , "Consequence Issued", "SIBAL MESSAGE: The Attached Consequence has been issed. Please Log into Sibal and deal with this incident.", NO

Exit_cmdMail7_Click:
Exit Function

Err_cmdMail7_Click:
MsgBox Err.Description
Resume Exit_cmdMail7_Click

as then you can just call the function for each button you need it for with
sendReport("email@address.com")
in the code for each button
 
SendObject

Although for a couple days it worked now it is back not working :( I took the suggestion above and re-did the buttons with the coding... but now either which way I do it the button stops working after the first click
 

Users who are viewing this thread

Back
Top Bottom