p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


  Return to Index  

access thread: Exporting report to email does not work


Message #1 by "Vladimiro Cerni" <vladimiro.cerni@t...> on Wed, 26 Sep 2001 17:04:13
After changing my PC to a new one, with Access 97 and Win 98 as before, 

one of my small applications does not work any more. The message i get 

is "It is not possible to open the session for the email program. Check if 

it's working correctly".

I am using now Access 97 with outlook express 5.5.

here is the code i am using:



Public Sub Split()

On Error GoTo Err_Split



Dim db As Database

Dim qdf As QueryDef

Dim strSQL As String

Dim Totale2anni As Recordset

Dim rsCriteria As Recordset



Set db = CurrentDb

Set rsCriteria = db.OpenRecordset("agenti", dbOpenSnapshot)



rsCriteria.MoveFirst



Do Until rsCriteria.EOF

    strSQL = "SELECT * FROM Totale2anni WHERE "

    strSQL = strSQL & "[Codage] = '" & rsCriteria![Codage] & "'"

    

    'Msgbox strSQL

    db.QueryDefs.Delete "qrySplit"

    Set qdf = db.CreateQueryDef("qrySplit", strSQL)

    

    DoCmd.SendObject acSendReport, "rptTotale2anni", "RichTextFormat

(*.rtf)", rsCriteria![email], "", "", "Fatturato agente cliente"

    

    rsCriteria.MoveNext

    

    Loop

    

    rsCriteria.Close

    

   

    

Exit_Split:

      Exit Sub

      

    

    

Err_Split:      

        If Err.Number = 3265 Or Err.Number = 2501 Then

        Resume Next

         Else

         MsgBox Err.Description

         Resume Exit_Split

         End If



  

    End Sub
Message #2 by Brian Skelton <brian.skelton@b...> on Thu, 27 Sep 2001 00:30:30 +0100
It sounds like your email program isn't registered properly, or Access 

has mis-installed a DLL file. Does it work in other circumstances? For 

example, if you click on an email link in your web browser does it open? 

Or send a document from the Word file menu? If neither of these work 

then Outlook would seem to be the problem. Unistall it completely and 

reinstall.



If other email aware applications work, then it would be worthwhile 

completely uninstalling Office (have a look at Knowledgebase article 

Q219423 to make sure you don't miss any files) and then reinstalling.



-BDS



-----Original Message-----

From:	Vladimiro Cerni [SMTP:vladimiro.cerni@t...]

Sent:	26 September 2001 18:04

To:	Access

Subject:	[access] Exporting report to email does not work



After changing my PC to a new one, with Access 97 and Win 98 as before,

one of my small applications does not work any more. The message i get

is "It is not possible to open the session for the email program. Check 

if

it's working correctly".

I am using now Access 97 with outlook express 5.5.

here is the code i am using:



Public Sub Split()

On Error GoTo Err_Split



Dim db As Database

Dim qdf As QueryDef

Dim strSQL As String

Dim Totale2anni As Recordset

Dim rsCriteria As Recordset



Set db =3D CurrentDb

Set rsCriteria =3D db.OpenRecordset("agenti", dbOpenSnapshot)



rsCriteria.MoveFirst



Do Until rsCriteria.EOF

    strSQL =3D "SELECT * FROM Totale2anni WHERE "

    strSQL =3D strSQL & "[Codage] =3D '" & rsCriteria![Codage] & "'"

   

    'Msgbox strSQL

    db.QueryDefs.Delete "qrySplit"

    Set qdf =3D db.CreateQueryDef("qrySplit", strSQL)

   

    DoCmd.SendObject acSendReport, "rptTotale2anni", "RichTextFormat

(*.rtf)", rsCriteria![email], "", "", "Fatturato agente cliente"

   

    rsCriteria.MoveNext

   

    Loop

   

    rsCriteria.Close

   

  

   

Exit_Split:

      Exit Sub

     

   

   

Err_Split:     

        If Err.Number =3D 3265 Or Err.Number =3D 2501 Then

        Resume Next

         Else

         MsgBox Err.Description

         Resume Exit_Split

         End If



 

    End Sub




  Return to Index