Solved

SendObject Cause "Illegal Operation Error"

Posted on 2001-06-21
9
198 Views
Last Modified: 2009-12-16
Hello.  I created a database in Access 97.  It has since been upgraded to Access 2000.  I am not really sure when the problem started since I am not over the database any more.  I got a call from the girl who upgraded and is now working on it.

There is a button that sends email under certain conditions.  For some reason when it get to the SendObject, it gives the error message "Illegal Operation and then the database shuts down.

Are there any References that need to be changed other than the Access 9.0?
I will appreciate any help.  But it might be Monday or so before I can get back with every one.  The database is in another building here on site. I am still using Access 97 so I will have to go over there to try any suggestions.  I will try to exlpain them to the girl over the phone first.

WonHop
0
Comment
Question by:WonHop
  • 5
  • 4
9 Comments
 
LVL 6

Expert Comment

by:PsychoDazey
ID: 6216516
If she upgraded to a2000, she may have also upgraded to outlook 2000.  Make sure the references are set for the latest version of outlook.
I am sending some code after this comment that will do the trick if that doesn't work.
0
 
LVL 6

Accepted Solution

by:
PsychoDazey earned 150 total points
ID: 6216528
This is using outlook to send the email.
Sub SendMessage(DisplayMsg As Boolean, Optional AttachmentPath)
          Dim objOutlook As Outlook.Application
          Dim objOutlookMsg As Outlook.MailItem
          Dim objOutlookRecip As Outlook.Recipient
          Dim objOutlookAttach As Outlook.Attachment

          Set objOutlook = CreateObject("Outlook.Application")

          Set objOutlookMsg = objOutlook.CreateItem(olMailItem)

          With objOutlookMsg
              ' Add the To recipient(s)
              Set objOutlookRecip = .Recipients.Add("Nancy Davolio")
              objOutlookRecip.Type = olTo

              ' Add the CC recipient(s)
              Set objOutlookRecip = .Recipients.Add("Michael Suyama")
              objOutlookRecip.Type = olCC

             ' Add the BCC recipient(s)
              Set objOutlookRecip = .Recipients.Add("Andrew Fuller")
              objOutlookRecip.Type = olBCC

             ' Set the Subject, Body, and Importance
             .Subject = "This is an Automation test with Microsoft Outlook"
             .Body = "This is the body of the message." & vbCrLf & vbCrLf
             .Importance = olImportanceHigh  'High importance

             ' Add attachments
             If Not IsMissing(AttachmentPath) Then
                 Set objOutlookAttach = .Attachments.Add(AttachmentPath)
             End If

             ' Resolve each Recipient's name.
             For Each objOutlookRecip In .Recipients
                 objOutlookRecip.Resolve
             Next

             ' Display the message before sending?
             If DisplayMsg Then
                 .Display
             Else
                 .Save
                 .Send
             End If
          End With
          Set objOutlook = Nothing
      End Sub
0
 
LVL 2

Author Comment

by:WonHop
ID: 6218430
Thanks for responding PsychoDazey.

They were already using Office 2000.  They considered the Access Licences to expensive to give to everyone, so they held Access 2000 back until recently.  That is when they upgraded the database.  So the references were already set for Outlook 2000.  She says that it worked for a while in Access 2000.  I cannot verify that.  
Could the database be corrupted or damaged in some way.
Are there any Access 2000 references like from DAO to ADO or something like that?  Something that needs to be added to Access 2000 that Access 97 did not need?

Regarding your comment.  I see how it works.  Writing the code the way you have it here, does that keep you from having to use the SendObject Function or is this another way of writing the SendOject?

WonHop
0
 
LVL 6

Expert Comment

by:PsychoDazey
ID: 6218576
You dont have to use the sendobject function with that code, it uses the outlook object.  You will have to set a reference to Outlook to use it.
Maybe you should try changing which version of DAO you are referencing?  i.e.- if you are referencing 3.6, change to 3.51 or 2.51 - 3.51
0
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 
LVL 2

Author Comment

by:WonHop
ID: 6218615
Thanks PsychoDazey.  I will send the infomation over there.  Like I said earlier, I might have to go over and do it.  It might be later today or more like Monday.  I would like to thank you in advance for your patience.

I am trying to get another project that I am working on to the point where I can ask another question about a Where Clause and get it solved first.

Thanks
WonHop
0
 
LVL 6

Expert Comment

by:PsychoDazey
ID: 6218645
No problem, I have a cd full of sample code for manipulating outlook within access, so let me know if you need more help with this.
0
 
LVL 2

Author Comment

by:WonHop
ID: 6218729
Thanks
0
 
LVL 2

Author Comment

by:WonHop
ID: 6233049
Hello PsychoDazey.  Sorry I am just now getting back to you.  That solution worked great.
Thanks for all of your help

WonHop
0
 
LVL 6

Expert Comment

by:PsychoDazey
ID: 6233438
Thats ok, I've been travelling all week anyway.  I am glad the code worked out for you!
0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Join & Write a Comment

Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now