SendObject Report (1 Viewer)

Carps

New member
Local time
Today, 15:03
Joined
Oct 3, 2002
Messages
5
Hello,

Can anyone help me I have converted an Access 97 database to 2000. Within the database I created a module which sends an email with a report attached.

The report is based on a query which is created using createquerydef command which selects the specific data from a table and sends to the appropriate person within a loop, this works fine in 97 but now I have converted the database I am having a few problems.

When I send the emails using Access 2000 it seems to open the report for a milli second but doesn't send it.

Can anyone offer an answers as to why this is happening.

Many Thanks
Carps.
 

Carps

New member
Local time
Today, 15:03
Joined
Oct 3, 2002
Messages
5
Code

Thanks
Attached is the structure of the code i am using this is working fine in 97 but not in Access 2000 is there a problem using the sendobject command in 2000 or the createquerydef. When i step through the code, it gets to docmd.sendobject pauses and doesn't do anything.


mySQL = "SELECT EMAIL ADDRESS FROM TABLE
Set rst = dbs.OpenRecordset(mySQL)
rst.MoveLast
rcount = rst.RecordCount
rst.MoveFirst


mailadd = Person email is to from above table
mailadd2 = cc email to
myreport = "report report all depts"
rptname = "Aged debts report"


mySQL2 = SELECT FIELDS FOR REPORT FROM VARIOUS TABLES RELEVANT TO EMAIL ADDRESS SELECTED

Set qdf = dbs.CreateQueryDef(QUERY, mySQL2)
DoCmd.OpenReport myreport, acViewPreview

RUN FUNCTION TO SEND REPORT *ATTACHED BELOW
sendreport myreport, rptname, mailadd, mailadd2

DoCmd.DeleteObject acQuery, QUERY
DoCmd.Close acReport, myreport, acSaveNo
Next

MOVE TO NEXT EMAIL ADDRESS
rst.MoveNext
Next i
rst.Close
dbs.Close
Exit Sub
----------------------------------------------------------------------------

Function sendreport(myreport, rptname, mailadd, mailadd2)
On Error GoTo sendreport_Err
Dim subtxt As String, msgtxt As String

subtxt = rptname
msgtxt = BLAH BLAH BLAH

DoCmd.SendObject acReport, myreport, acFormatRTF, mailadd, mailadd2, "", subtxt, msgtxt, False

sendreport_Exit:
Exit Function

sendreport_Err:
MsgBox Error$
Resume sendreport_Exit

End Function
 
Last edited:

bradcccs

Registered User.
Local time
Tomorrow, 00:03
Joined
Aug 9, 2001
Messages
461
I don't understand the need for the function to utilise the sendobject action.

I would suggest replacing:

If mailadd2 > "" Then ***** possible error due to > "" (<>)
sendreport myreport, rptname, mailadd, mailadd2
End If

If mailadd2 = "" Then
sendreport2 myreport, rptname, mailadd
End If

With the actual send object command line.

DoCmd.SendObject acReport, myreport, acFormatRTF, mailadd, mailadd2, , subtxt, msgtxt, False

You could still handle the CC being "" if you wish. However, try:

If mailadd2 = "" Then
docmd.sendobject .....without CC
Else
docmd.sendobject ......with CC
End if

I am way to tired to read through your SQL and dlookups, but given that you said the report opens, I am guessing that is under control.

IF you still have probs, replace the docmd.sendobject lines with msgbox's in order to see where the sub is exiting. I noticed that the error control has a resume next statement, so it may be aborting prior to docmd (or function in your case) anyway.

Cheers

Brad.
 

Carps

New member
Local time
Today, 15:03
Joined
Oct 3, 2002
Messages
5
I am having no joy any more ideas

Thanks
Carps
 

Users who are viewing this thread

Top Bottom